Application logs are often critical in troubleshooting, but, in a busy system it can be hard to disentangle interleaved log messages to see those for a particular transaction. One approach is to assign each transaction unique identifiers that are included in the log message. The identifiers must then propagate through concurrency mechanisms, such as threaded or asynchronous processing, and across distributed services. SolarWinds Observability APM libraries enable this functionality through trace context.
When a request enters an instrumented application, the APM libraries create a unique trace context and maintain that context through the lifetime of the transaction. The trace context is included when the library reports performance metrics, the transaction trace, if sampled, and to your application logs, if enabled.
Adding trace context to application logs provides the ability to correlate the log messages from a traced transaction, and, if sampled, the log messages to the transaction trace detail.
Application logs for your service entity are not included in the data sent by APM libraries. Configure your server or application to send application logs to SolarWinds Observability. See Add logs from services.
The trace context inserted into application logs takes the form of a TraceID, a SpanID, and Trace Flags.
The Trace ID is a hex string that represents the associated transaction trace. This Trace ID can also be seen in the Transaction Details page of the Traces Explorer. An example Trace ID is:
The Span ID is a hex string representing the associated span. This Span ID can be seen in the Span panel of the Transaction Details page in the Traces Explorer. An example Span ID is:
The Trace Flags indicates whether the trace was sampled;
01 means there was a corresponding sampled trace and
00 means no trace was sampled.
Trace context in logs is disabled by default. See the links below on how to enable this feature in each library, supported logging libraries and SDK examples: