Troubleshooting OpenTelemetry
The following information can help you determine the cause of common problems and error messages that are associated with OpenTelemetry logs, metrics, and tracing. To help debug issues with your OpenTelemetry logs, metrics, or traces, you can export this data to the console for analysis.
Exporting logs, metrics, or traces to the console for debugging purposes
By default, all OpenTelemetry data is exported to the otlp
exporter. For debugging purposes, you can temporarily change the export destination to the console.log
file by setting the otel.< signal >.exporter=console
property at the application or the runtime level.
For example, to send all application and runtime traces to the console.log
file, you might set the following property in the bootstrap.properties
file:
otel.traces.exporter=console
Similarly, to send all application and runtime logs to the console.log
file, set the following property in the bootstrap.properties
file:
otel.logs.exporter=console
When you configure the logs exporter to console
, log records are sent immediately, instead of in batches like they are when the default otlp
exporter is used.
To send all application and runtime metrics to the console.log
file, set the following property in the bootstrap.properties
file:
otel.metrics.exporter=console
If you enabled OpenTelemetry at the application level and you want to send only the logs, metrics, or traces for a particular application to the console, set the corresponding property in the microprofile-config.properties
file for the application.
Common problems and error messages
- Previous spans are incorrectly shown as current or parent spans
If the
Scope
instance is not closed correctly, the context and baggage values of previous spans might remain when the next operation runs. Alternatively, the current span might remain and be picked up as the parent of the next operation that runs.Always close the
Scope
instance when you exit an operation. This configuration stops the span from being current and makes the previous span current again. Use atry-with-resources
block, which automatically closes theScope
instance at the end of the block, as shown in the following example:Span span = tracer.spanBuilder("PerformingOperation").startSpan(); try (Scope scope = span.makeCurrent()) { ... } finally { span.end(); }
- You receive the
CWMOT5100I
message that tracing is disabled If you enable the
mpTelemetry-1.1
ormpTelemetry-1.0
feature, you must also set theotel.sdk.disabled=false
property in any of the configuration sources that are accessible through MicroProfile Config to enable tracing.- You receive the CWMOT5003W message that the application attempted to acquire MicroProfile Telemetry after shut down
Review the application to see why it attempted to use MicroProfile Telemetry after it shut down. Actions that might trigger MicroProfile Telemetry include calling a method that is annotated with
@WithSpan
or making a request with a JAX-RS Client or MP Rest Client.- You receive either of the CWMOT5006W or CWMOT5007 warning message that conflicting configuration is specified for otel.sdk.disabled
Specify the settings to enable or disable OpenTelemetry instances by using either environment variables or MicroProfile Config sources, but not both. If you see these warnings, the other MicroProfile Config source to look at is your
server.xml
file.