Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic injection is enabled, but trace_id is null in MDC context. #7495

Open
sinbom opened this issue Aug 23, 2024 · 0 comments
Open

Automatic injection is enabled, but trace_id is null in MDC context. #7495

sinbom opened this issue Aug 23, 2024 · 0 comments

Comments

@sinbom
Copy link

sinbom commented Aug 23, 2024

DD_LOGS_INECTION
Environment Variable: DD_LOGS_INJECTION
Default: true
Enabled automatic MDC key injection for Datadog trace and span IDs. See Advanced Usage for details.

String traceId = MDC.get("dd.trace_id"); // null
String spanId = MDC.get("dd.span_id"); // null

I'm trying to access trace_id, span_id injected into MDC context in application code with DD_LOGS_INCTION option enabled. but, no value is injected into the MDC and NULL is returned.

"dd.trace_id":"%X{dd.trace_id}", "dd.span_id":"%X{dd.span_id}"

What I didn't understand is that when I output the logs, if I use the format in logback-spring.xml that uses the trace_id, span_id keys of the MDC context, the values are present in the output logs. I already know that if I add the dd-trace-api dependency to my project and use CorrelationIdentifier, it returns trace_id, span_id. I would like to avoid adding dependencies if possible. The documentation describes the keys as being automatically injected into the MDC context, do I necessarily need to use CorrelationIdentifier to access them?

@sinbom sinbom changed the title Automatic injection is enabled, but trace_id is NULL in MDC context. Automatic injection is enabled, but trace_id is null in MDC context. Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant