-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SentryJsonProcessor breaks logging breadcrumbs #25
Comments
Bump for breadcrumbs support. I have written some code of my own to let Sentry's But would love to start using |
When making the transition from the standard logging to structlog I tried |
I write this wrapper for fixing the breadcrumb issue: TLDR: grab all events, compare level with |
@paveldedik We used wrapper for catching breadcrumbs a few months in our production. What do you think if I create a pull request with it into upstream SentryJsonProcessor? |
@b0g3r I guess the following config should work fine? LOGGING = {
"version": 1,
"disable_existing_loggers": True,
"formatters": {
"json_formatter": {
"()": structlog.stdlib.ProcessorFormatter,
"processor": structlog.processors.JSONRenderer(),
},
"plain_console": {
"()": structlog.stdlib.ProcessorFormatter,
"processor": structlog.dev.ConsoleRenderer(),
},
"key_value": {
"()": structlog.stdlib.ProcessorFormatter,
"processor": structlog.processors.KeyValueRenderer(key_order=["timestamp", "level", "event", "logger"]),
},
},
"handlers": {
"console": {
"level": "DEBUG",
"class": "logging.StreamHandler",
"formatter": "json_formatter",
}
},
"root": {"level": "INFO", "handlers": ["console"]},
"loggers": {
"django.db.backends": {
"level": "ERROR",
"handlers": ["console"],
"propagate": False,
},
# Errors logged by the SDK itself
"sentry_sdk": {"level": "ERROR", "handlers": ["console"], "propagate": False},
"django.security.DisallowedHost": {
"level": "ERROR",
"handlers": ["console"],
"propagate": False,
},
},
}
structlog.reset_defaults()
structlog.configure(
processors=[
structlog.stdlib.filter_by_level,
structlog.processors.TimeStamper(fmt="iso"),
structlog.stdlib.add_logger_name,
structlog.stdlib.add_log_level,
SentryBreadcrumbJsonProcessor(level=logging.ERROR),
structlog.stdlib.PositionalArgumentsFormatter(),
structlog.processors.StackInfoRenderer(),
structlog.processors.format_exc_info,
structlog.processors.UnicodeDecoder(),
structlog.stdlib.ProcessorFormatter.wrap_for_formatter,
],
context_class=structlog.threadlocal.wrap_dict(dict),
logger_factory=structlog.stdlib.LoggerFactory(),
wrapper_class=structlog.stdlib.BoundLogger,
cache_logger_on_first_use=True,
)
# Sentry
# ------------------------------------------------------------------------------
SENTRY_DSN = env("SENTRY_DSN")
SENTRY_LOG_LEVEL = env.int("DJANGO_SENTRY_LOG_LEVEL", logging.INFO)
sentry_logging = LoggingIntegration(
level=SENTRY_LOG_LEVEL, # Capture info and above as breadcrumbs
event_level=logging.ERROR, # Send errors as events
)
sentry_sdk.init(
dsn=SENTRY_DSN,
release=env("GIT_COMMIT", "unspecified"),
integrations=[
sentry_logging,
DjangoIntegration(),
CeleryIntegration(),
RedisIntegration(),
],
traces_sample_rate=env.float("SENTRY_TRACES_SAMPLE_RATE", 0.25),
) |
@b0g3r @paveldedik I think what you both have contributed above in your comments should be merged in, yes (documentation and code updates). 👍 from this random internet person |
Hi, sorry for the late response, @aexvir gave me the permissions to merge PRs again, so I could take care of the issues. I released a new BETA version of structlog-sentry It still needs to be tested properly in production (I am currently testing it) so it would be nice if some of you could test it too. Especially fixed breadcrumbs should be part of the new version, So please, if you have time to test I'm going to close this issue now as it should be fixed, feel free to open a new issue or reopen this one if you still have issues after upgrading to the beta version. |
When using
SentryJsonProcessor
no logging breadcrumbs show up in sentry.More info: #15
The text was updated successfully, but these errors were encountered: