Can't use structlog.stdlib.ProcessorFormatter with structlog_sentry.SentryProcessor
yoshi-lyosha opened this issue · 1 comments
At first, guys, thanks for the very useful lib!
I've tried to achieve the same logging format for both logging
and structlog
packages. Next I've tried to configure sentry in compound with structlog
and structlog_sentry
. All is good, but I have one issue that bothers me a lot.
structlog.stdlib.ProcessorFormatter
have try/except closure to detect was the record wrapped by structlog.stdlib.ProcessorFormatter.wrap_for_formatter
or not.
https://github.com/hynek/structlog/blob/9aa02f2bdacf57b9ea943ff7f3e82d0840032bf4/src/structlog/stdlib.py#L502-L511
And structlog_sentry.SentryProcessor
by design on each record tries to extract exc_info
if record has suitable level.
In the case like
logging.getLogger("default_logging_logger").error("some simple error")
I will get
in Sentry, that is not correct.
The issue covers in structlog_sentry.SentryProcessor._get_event_and_hint
in
I'd like to propose to use in SentryProcessor
exc_info = event_dict.get("exc_info", False)
instead of True
as default value of event_dict.get
Expected behaviour is to get just an error without bounded exc_info
if exc_info=True
didn't passed explicitly.
Here is gist of my code with structlog
/ logging
configuration + logger.error()
call:
https://gist.github.com/yoshi-lyosha/9766b6759b674297fcc698a331ba6ca6