You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have been using structlog for a while, along with the ExceptionDictTransformer processor, which integrates wonderfully with DataDog. Recently, we encountered a minor but frustrating issue in our production environment. This issue arose from logging exceptions without the exc_info parameter, for example.
The issue occurs because ExceptionDictTransformer calls extract before exc_info verification opposed to _format_exception which returns MISSING
full trace:
--- Logging error ---
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/logging/__init__.py", line 1110, in emit
msg = self.format(record)
^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/logging/__init__.py", line 953, in format
return fmt.format(record)
^^^^^^^^^^^^^^^^^^
File "/Users/kernel-panic/cronenberg/venv/lib/python3.11/site-packages/structlog/stdlib.py", line 1059, in format
ed = proc(logger, meth_name, ed)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/kernel-panic/cronenberg/venv/lib/python3.11/site-packages/dd_json_logger/custom_processors.py", line 85, in format_exception_as_json
return ExceptionRenderer(ExceptionDictTransformer(show_locals=False))(logger, name, event_dict)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/kernel-panic/cronenberg/venv/lib/python3.11/site-packages/structlog/processors.py", line 412, in __call__
event_dict["exception"] = self.format_exception(
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/kernel-panic/cronenberg/venv/lib/python3.11/site-packages/structlog/tracebacks.py", line 262, in __call__
trace = extract(
^^^^^^^^
File "/Users/kernel-panic/cronenberg/venv/lib/python3.11/site-packages/structlog/tracebacks.py", line 156, in extract
exc_type=safe_str(exc_type.__name__),
^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute '__name__'
The text was updated successfully, but these errors were encountered:
We have been using structlog for a while, along with the ExceptionDictTransformer processor, which integrates wonderfully with DataDog. Recently, we encountered a minor but frustrating issue in our production environment. This issue arose from logging exceptions without the exc_info parameter, for example.
The issue occurs because
ExceptionDictTransformer
calls extract beforeexc_info
verification opposed to_format_exception
which returns MISSINGfull trace:
The text was updated successfully, but these errors were encountered: