Error handling in OpenTelemetry and Datadog
This page documents common pitfalls and best practices when working with errors, logs, and status handling in OpenTelemetry and Datadog.
The page will grow over time as new issues and solutions are discovered.
Incorrect Log Levels in Datadog
Q: Why do my logs show the wrong log level in Datadog?
Datadog's default log parsing interprets the status attribute as the log level.
If this attribute is set incorrectly, Datadog may display the wrong log level.
Note
In Datadog this field is called Status, not Log Level.
The following excerpt is from Datadog's documentation:
Each incoming status value is mapped as follows:
Integers from 0 to 7 map to the Syslog severity standards
Strings beginning with emerg or f (case-insensitive) map to emerg (0)
Strings beginning with a (case-insensitive) map to alert (1)
Strings beginning with c (case-insensitive) map to critical (2)
Strings beginning with err (case-insensitive) map to error (3)
Strings beginning with w (case-insensitive) map to warning (4)
Strings beginning with n (case-insensitive) map to notice (5)
Strings beginning with i (case-insensitive) map to info (6)
Strings beginning with d, t, v, trace, or verbose (case-insensitive) map to debug (7)
Strings beginning with o or s, or matching OK or Success (case-insensitive) map to OK
All others map to info (6)
status attribute is set to Completed, interprets this as a Critical entry because the word Completed starts with the letter c.
Warning
Do not use status as a log attribute unless you intend to control the Datadog log level.
Example with Serilog
If you are using a logging framework such as Serilog, avoid using status as a structured logging attribute.
The following Information log will be interpreted as Critical in Datadog: