question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Export all MDC contextual fields in logs when using otlp exporter

See original GitHub issue

Is 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:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
lauritcommented, Jun 22, 2022

Try using * instead of true -Dotel.instrumentation.logback-appender.experimental.capture-mdc-attributes=*

0reactions
kushal-ticommented, Jun 22, 2022

this seems to have worked thank you, i will close this issue now

Read more comments on GitHub >

github_iconTop Results From Across the Web

Export all MDC contextual fields in logs when using otlp exporter
When logs are exporter using otlp exporter, it only carries trace id, span id and trace flags from the MDC context and drop...
Read more >
oteps/0150-logging-library-sdk.md at main - GitHub
This is a draft proposal for OpenTelemetry Logging Library SDK specification. ... It is expected that the caller will populate trace context related...
Read more >
OTLP Exporter Configuration - OpenTelemetry
A list of headers to apply to all outgoing data (traces, metrics, and logs). Default value: N/A. Example: export OTEL_EXPORTER_OTLP_HEADERS="api ...
Read more >
[Java] OpenTelemetry agent data export interval
How often Open telemetry agent export logs and traces to New Relic by ... [Exporters](#exporters) + [OTLP exporter (span, metric, and log ......
Read more >
Java Log Collection - Datadog Docs
Ensure that all log event attributes (such as severity, logger name, and thread name) are properly extracted. Gain access to Mapped Diagnostic Context...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found