Logging integration to capture all logged exceptions
See original GitHub issueIs your feature request related to a problem? Please describe.
Instrumenting an existing application can be cumbersome: All places with exception handling need to be extend in order to also forward the errors to APM using client.capture_exception()
. However, most of the time such code paths are already well covered with logger.exception(...)
or similar.
Describe the solution you’d like The APM library should offer an opt-in feature to automatically forward all logged exceptions to APM. This could be an automatic feature similar to how HTTP libraries get instrumented.
Describe alternatives you’ve considered
The APM logging.LoggingHandler
class offers such functionality. However the capturing is hereby bound to a specific output format. It cannot easily be used together with structlog
This feature request is inspired by the integration offered by Sentry https://docs.sentry.io/platforms/python/guides/logging/.
Additional context n/a
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top GitHub Comments
For celery integration, if an exception happens outside a task, then it isn’t forwarded. I didn’t see excepthook. I’ll try it out.
Theoretically we’re already forwarding unhandled exceptions via our framework integrations. Plus you can use our excepthook to make the capturing behavior even more broad.
But perhaps it’s worth adding another place in
structlog
as in your example. Thanks for the input, it’s really valuable!