-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Include exception type and reason in structured logging json #10209
Comments
I think the text should already be included? |
The synapse/synapse/metrics/background_process_metrics.py Lines 216 to 219 in e9f2ad8
Which resulted in:
Which doesn't seem to include any useful exception information... unless it's getting lost in this specific instance? |
Yeah that's not great. Thanks for clarifying! |
It might also be useful to include the file / line where the exception happened, if that info exists...but again I don't think we want to re-implement Sentry here. 😄 |
Knowing at least the exception type would significantly help us at Beeper and is more than enough. For more complex debugging, I would definitely prefer using Sentry instead. The reason we (Beeper) would like this feature was mostly so we can look at logs on startup, identify an error based on the exception type, and go quickly fix that. |
Also an issue with request handling failures: This code block here: synapse/synapse/http/server.py Lines 93 to 98 in 4b965c8
precise output:
structured output:
without a backtrace |
Currently when structured logging is enabled (using either the
JsonFormatter
orTerseJsonFormatter
),logger.exception
lines don't include a traceback nor any exception information at all (other than what's presented in the string passed tologger.exception
.This is due to us ignoring the
exc_text
andexc_info
attributes of the log record when during formatting:synapse/synapse/logging/_terse_json.py
Lines 23 to 31 in 18edc9a
While it's not quite feasible to include full tracebacks in structured logging (one should use a tool like Sentry.io for that), it may be useful to include the exception type ((i.e
psycopg2.OperationalError
) and text (i.eFATAL: sorry, too many clients already
) as structured fields. This will give sysadmins a clue as to what might be going wrong, whereas Sentry is useful for pointing out the line where the issue occurred (and thus where developers may be able to go in and fix the issue).The text was updated successfully, but these errors were encountered: