- Basic Event Logging in OpenTelemetry: Logs key events during the execution of a code path to a trace span, providing insights into specific actions within your application’s workflow.
- Error Handling with Span Status in OpenTelemetry: Marks a trace span with an error status when an exception occurs, helping to identify and troubleshoot issues in distributed systems.
- Error Handling and Exception Recording in OpenTelemetry: Sets a span’s status to error and records detailed information about exceptions, offering a comprehensive view of failures for more effective debugging.
Adding events
Span Events are human-readable messages that represent “something happening” at a particular moment during the lifetime of a span. You can think of it as a primitive log.- Python
- JS/TS
- Java
Set span status
The Span Status allows you to signal the success or failure of the code executed within the span. It is typically used to specify that a Span has not completed successfully -Error. By default, all spans are Unset, which means a span completed without error. The Ok status is reserved for when you need to explicitly mark a span as successful rather than stick with the default of Unset (i.e., “without error”).
The status can be set at any time before the span is finished.
- Python
- JS/TS
Record exceptions in spans
It can be a good idea to record exceptions when they happen. It’s recommended to do this in conjunction with setting span status.- Python
- JS/TS