Export all MDC contextual fields in logs when using otlp exporter
See original GitHub issueIs your feature request related to a problem? Please describe. When logs are exporter using otlp exporter, it only carries trace id, span id and trace flags from the MDC context and drop all other contextual variables
Describe the solution you’d like I have some contextual MDC variables along side trace_id and span_id that i can see is being printed to console when i run the application. However, when these logs are being sent to the otlp collector, it drops all other variables and just propagates the trace_id and span_id
Describe alternatives you’ve considered I have considered having my contextual fields injected directly into the body of the log itself (my ultimate goal is to export the logs to GCP Cloud logging and according to a doc here, the Body field from OTLP logs is translated as the json payload for GCP logs )
Additional context Logs as printed to console from logback
{
"custom_fields":["field1","field2"], # these are injected into logs because they're part of MDC
"trace_id":"bc9e21df9f1706fbd66328287262c4fe","trace_flags":"01","span_id":"ffd8408475188bbb",
"timestampSeconds":1655725661,"timestampNanos":575000000,
"severity":"INFO","logger":"root","message":"my log message"
}
Logs after being collector in otel collector and exporter to stdout (using logging exporter)
Resource SchemaURL: https://opentelemetry.io/schemas/1.9.0
Resource labels:
-> container.id: STRING(3942)
-> host.arch: STRING(amd64)
-> os.description: STRING(Linux 5.13.0-48-generic)
-> os.type: STRING(linux)
-> process.command_line: STRING(/usr/lib/jvm/java-17-openjdk-amd64:bin:java -Xverify:none -javaagent:opentelemetry-javaagent.jar -Dotel.resource.attributes=service.name=pipeline -Dotel.traces.exporter=none -Dotel.metrics.exporter=none -Dotel.logs.exporter=otlp)
-> process.executable.path: STRING(/usr/lib/jvm/java-17-openjdk-amd64:bin:java)
-> process.pid: INT(83220)
-> process.runtime.description: STRING(Private Build OpenJDK 64-Bit Server VM 17.0.3+7-Ubuntu-0ubuntu0.20.04.1)
-> process.runtime.name: STRING(OpenJDK Runtime Environment)
-> process.runtime.version: STRING(17.0.3+7-Ubuntu-0ubuntu0.20.04.1)
-> service.name: STRING(pipeline)
-> telemetry.auto.version: STRING(1.15.0)
-> telemetry.sdk.language: STRING(java)
-> telemetry.sdk.name: STRING(opentelemetry)
-> telemetry.sdk.version: STRING(1.15.0)
ScopeLogs #0
ScopeLogs SchemaURL:
InstrumentationScope in.co.codenation.cap.cg_finders_pipeline.controllers.ProbeController
LogRecord #0
ObservedTimestamp: 1970-01-01 00:00:00 +0000 UTC
Timestamp: 2022-06-20 11:47:41.575 +0000 UTC
Severity: INFO
Body: my log message
Trace ID: bc9e21df9f1706fbd66328287262c4fe # only gets TraceId and SpanId. Custom fields are dropped entirely
Span ID: ffd8408475188bbb
Flags: 1
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Try using
*
instead oftrue
-Dotel.instrumentation.logback-appender.experimental.capture-mdc-attributes=*
this seems to have worked thank you, i will close this issue now