Status: Stable
Table of Contents
OTLP Logs Records have top level fields representing trace context. This document defines how trace context should be recorded in non-OTLP Log Formats. To summarize, the following field names should be used in legacy formats:
- "trace_id" for TraceId, lowercase and hex-encoded.
- "span_id" for SpanId, lowercase and hex-encoded.
- "trace_flags" for trace flags, formatted according to W3C traceflags format.
All 3 fields are optional (see the data model for details of which combination of fields is considered valid).
Trace id, span id and traceflags SHOULD be recorded via SD-ID "opentelemetry".
For example:
[opentelemetry trace_id="102981abcd2901" span_id="abcdef1010" trace_flags="01"]
The fields SHOULD be recorded according to the customary approach used for a particular format (e.g. field:value format for LTSV). For example:
host:192.168.0.1<TAB>trace_id:102981abcd2901<TAB>span_id:abcdef1010<TAB>time:[01/Jan/2010:10:11:23 -0400]<TAB>req:GET /health HTTP/1.0<TAB>status:200
The fields SHOULD be recorded as top-level fields in the JSON structure. For example:
{
"timestamp":1581385157.14429,
"body":"Incoming request",
"trace_id":"102981abcd2901",
"span_id":"abcdef1010"
}
The fields SHOULD be recorded as top-level structured attributes of the log record as it is customary for the particular format.