Trace ID
A trace ID is an identifier attached with the same value to every span that a single request passed through. If this value is also in the logs, you can move back and forth between a log line and the trace of that request.
Overview
What links logs and traces is a match of this value present in both. The trace ID is a 128-bit value; Datadog-format headers carry the lower 64 bits in decimal, while logs in OpenTelemetry form write the whole value as 32 hexadecimal characters. It is the concept to keep in mind when related logs do not appear on the trace screen, or when the value looks different between OpenTelemetry and Datadog even though it is the same request.
Decided once at the entry point, with the same value on every span
When a request reaches the first service, the trace ID is decided, and every span created while processing that request gets the same value. The mechanism for passing this value in headers when crossing services is left to the explanation in Distributed Tracing. In practice it comes into play when linking with records outside the trace. When a log line contains the trace ID and span ID as attributes, you can look up records of the same request in either direction between APM and Log Management (as of October 2026; Source: Correlate Logs and Traces). If the value is missing or its form does not match, the records of the same incident stay split across two screens.
Why the value appears to differ from OpenTelemetry
The trace ID is a 128-bit value, but the Datadog-format header x-datadog-trace-id carries only its lower 64 bits, written in decimal. The upper 64 bits are carried in hexadecimal inside x-datadog-tags (as of October 2026; Source: Trace Context Propagation). In OpenTelemetry logs sent via files, trace_id is 32 lowercase hexadecimal characters (as of October 2026; Source: Correlating OpenTelemetry Traces and Logs).
| Where it is written | Range carried | Notation |
|---|---|---|
x-datadog-trace-id header | Lower 64 bits of the trace ID | Decimal |
x-datadog-tags header | Upper 64 bits of the trace ID (together with other accompanying information) | Hexadecimal |
x-datadog-parent-id header | 64-bit ID of the span being processed | Decimal |
trace_id in logs in OpenTelemetry form | The entire 128 bits of the trace ID | 32 lowercase hexadecimal characters |
Even when they point to the same request, one is a number of up to 20 digits and the other is 32 characters mixed with letters, so comparing them by eye shows no match. When you want to match them, the last 16 of the 32 hexadecimal characters correspond to the lower 64 bits, so convert that part to decimal and compare.
Putting the value into logs is the job of SDK injection
The trace ID ends up on the log side because the SDK writes the ID of the currently running span into the log context. The Java SDK injects automatically into JSON-formatted logs starting with 0.74.0 (earlier versions use DD_LOGS_INJECTION=true). The loggers supported for automatic injection are Log4j2 / Log4j / SLF4J and Logback. The name of the Attribute that goes in is dd.trace_id, and for JSON logs even the processing to copy it to the reserved attribute is done automatically (as of October 2026; Source: Correlating Java Logs and Traces). If you put it under a different name, add that name to the Trace ID setting in preprocessing (for the copying mechanism, see Remapper).
A span ID points to a single unit of work
The span ID that goes into logs alongside the trace ID points to a single unit of work within the request, that is, one Span. In logs in OpenTelemetry form, span_id is written as 16 lowercase hexadecimal characters, half the length of the trace ID. With both present, you can read a single log line linked all the way to the stage of processing at which it was written. For logs collected with the Datadog Agent, these OpenTelemetry standard names are also recognized automatically (as of October 2026; Source: Correlating OpenTelemetry Traces and Logs).
The order to check when you cannot move to the trace
When the attribute and the form of the value both match but there is no trace, it is not necessarily a configuration error. Logs and traces are sampled separately, so the trace for an ID remaining in the logs may not have been ingested (as of October 2026; Source: Correlate Logs and Traces). How sampling is decided is summarized in Sampling. One way to proceed is to open one log line that cannot move to its trace and first check whether its attributes include dd.trace_id or trace_id. If they do, check whether the value is a decimal number or 32 hexadecimal characters against how the sending SDK or Collector writes it. If they do not, fix the injection settings or the parsing rules. For raw logs that are not JSON, putting the language name in the source attribute lets the language integration read them (as of October 2026; Source: Correlated Logs Are Not Showing Up In The Trace ID Panel). With custom parsing rules, extract the ID as a string.