Documentation forSolarWinds Observability

Trace context in logs

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.

Trace context

The trace context inserted into application logs takes the form of a TraceID, a SpanID, and Trace Flags.

Trace ID

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: abcdef1234567890abcdef1234567890.

Span ID

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: 1234abcd1234abcd.

Trace Flags

The Trace Flags indicates whether the trace was sampled; 01 means there was a corresponding sampled trace and 00 means no trace was sampled.

Enabling

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: