The spec for log formatting, specifically JSON has an example:
https://opentelemetry.io/docs/specs/otel/compatibility/logging_trace_context/#json-formats
Which seems to reinforce the overview of logging Trace ID and Span ID in legacy 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.
However, the log record that is created with the opentelemetry-instrumentation-logging has fields named otelTraceID and otelSpanID, etc.:
|
record.otelSpanID = format(ctx.span_id, "016x") |
|
record.otelTraceID = format(ctx.trace_id, "032x") |
|
record.otelTraceSampled = ctx.trace_flags.sampled |
This doesn't rear it's head with standard text formatters as the default logging format pulls the appropriate log record attributes out explicitly:
|
DEFAULT_LOGGING_FORMAT = "%(asctime)s %(levelname)s [%(name)s] [%(filename)s:%(lineno)d] [trace_id=%(otelTraceID)s span_id=%(otelSpanID)s resource.service.name=%(otelServiceName)s trace_sampled=%(otelTraceSampled)s] - %(message)s" |
JSON formatters traditionally just take what they are given and spit them out, see reference implementation: python-json-logger.
I believe the attributes placed onto the log record should change to snake case, and the default text format changed to leverage them appropriately.
The spec for log formatting, specifically JSON has an example:
https://opentelemetry.io/docs/specs/otel/compatibility/logging_trace_context/#json-formats
Which seems to reinforce the overview of logging Trace ID and Span ID in legacy log formats:
However, the log record that is created with the opentelemetry-instrumentation-logging has fields named
otelTraceIDandotelSpanID, etc.:opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/__init__.py
Lines 203 to 205 in 26c975f
This doesn't rear it's head with standard text formatters as the default logging format pulls the appropriate log record attributes out explicitly:
opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/constants.py
Line 4 in 26c975f
JSON formatters traditionally just take what they are given and spit them out, see reference implementation: python-json-logger.
I believe the attributes placed onto the log record should change to snake case, and the default text format changed to leverage them appropriately.