Hello,
I upgraded to the latest sentry-sdk for Python last weekend, and now I am seeing that some exceptions are creating 10+ Sentry events, one for each line of the traceback:
When I click on an individual event, the usual collapsible traceback view is not there.
My Sentry config is:
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
sentry_sdk.init(
dsn=os.environ.get('SENTRY_DSN'),
integrations=[DjangoIntegration()],
send_default_pii=True,
)
Most exceptions are being automatically captured, although I can also reproduce this problem sometimes by calling capture_exception()
.
Any ideas? Thank you for your time.
You have a log handler somewhere that logs a message for each line of a stringified traceback. I don’t know were this logger.error
call is happening though.
Thank you @untitaker. I am using essentially the default Django logging config:
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'filters': {
'require_debug_false': {'()': 'django.utils.log.RequireDebugFalse'},
'require_debug_true': {'()': 'django.utils.log.RequireDebugTrue'},
},
'formatters': {
'django.server': {
'()': 'django.utils.log.ServerFormatter',
'format': '[%(server_time)s] %(message)s',
}
},
'handlers': {
'console': {
'level': 'INFO',
# 'filters': ['require_debug_true'],
'class': 'logging.StreamHandler',
},
'django.server': {
'level': 'INFO',
'class': 'logging.StreamHandler',
'formatter': 'django.server',
},
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler',
},
},
'loggers': {
'django': {'handlers': ['console', 'mail_admins'], 'level': 'INFO'},
'myproject': {'handlers': ['console'], 'level': 'INFO'},
'django.server': {
'handlers': ['django.server'],
'level': 'INFO',
'propagate': False,
},
},
}
The only change i made is in the ‘console’ handler, commenting out require_debug_true
. I guess that since the django.request logger logs the full tracebacks to the console, Sentry is sending those same messages line by line. I don’t fully understand why it splits them into multiple events if it’s just one call to logger.error, and why it matters whether it’s DEBUG, but anyway I’ve re-enabled the require_debug_true and hopefully that will make the error go away.
Thanks again!
Yeah, sorry I can’t be of more help. Another interesting thing is that the logs are going to a logger called root
, so it might be sensible to search your virtualenv packages for that string
OK i will, thank you very much!