Reputation: 2342
I have sentry in my django application. And sentry all the time print in the console
[sentry] DEBUG: Discarding transaction because sampled = False
[sentry] INFO: Discarded session update because of missing release
How can I disable this messages and why they appers?
This is how sentry is installed in django
sentry_sdk.init(
dsn=os.environ.get('SENTRY_DSN_PYTHON'),
integrations=[DjangoIntegration(), CeleryIntegration()],
debug=False
)
Upvotes: 0
Views: 5279
Reputation: 6189
docs on debug flag
Turns debug mode on or off. If debug is enabled SDK will attempt to print out useful debugging information if something goes wrong with sending the event. The default is always false. It's generally not recommended to turn it on in production, though turning debug mode on will not cause any safety concerns.
Logs you see use this flag.
My guess is you actually run sentry in debug mode.
Maybe try adding SENTRY_LOG_LEVEL=WARNING
environment variable?
The third solution would be to change log level in LOGGING.
Here's an example LOGGING setting for django project from sentry.
LOGGING = {
'default_level': 'INFO',
'version': 1,
'disable_existing_loggers': True,
'handlers': {
'null': {
'class': 'logging.NullHandler',
},
'console': {
'class': 'sentry.logging.handlers.StructLogHandler',
},
'internal': {
'level': 'ERROR',
'filters': ['sentry:internal'],
'class': 'sentry_sdk.integrations.logging.EventHandler',
},
'metrics': {
'level': 'WARNING',
'filters': ['important_django_request'],
'class': 'sentry.logging.handlers.MetricsLogHandler',
},
'django_internal': {
'level': 'WARNING',
'filters': ['sentry:internal', 'important_django_request'],
'class': 'sentry_sdk.integrations.logging.EventHandler',
},
},
'filters': {
'sentry:internal': {
'()': 'sentry.utils.sdk.SentryInternalFilter',
},
'important_django_request': {
'()': 'sentry.logging.handlers.MessageContainsFilter',
'contains': ["CSRF"]
}
},
'root': {
'level': 'NOTSET',
'handlers': ['console', 'internal'],
},
# LOGGING.overridable is a list of loggers including root that will change
# based on the overridden level defined above.
'overridable': ['celery', 'sentry'],
'loggers': {
'celery': {
'level': 'WARNING',
},
'sentry': {
'level': 'INFO',
},
'sentry.files': {
'level': 'WARNING',
},
'sentry.minidumps': {
'handlers': ['internal'],
'propagate': False,
},
'sentry.interfaces': {
'handlers': ['internal'],
'propagate': False,
},
# This only needs to go to Sentry for now.
'sentry.similarity': {
'handlers': ['internal'],
'propagate': False,
},
'sentry.errors': {
'handlers': ['console'],
'propagate': False,
},
'sentry_sdk.errors': {
'handlers': ['console'],
'level': "INFO",
'propagate': False,
},
'sentry.rules': {
'handlers': ['console'],
'propagate': False,
},
}
}
Upvotes: 1