Skip to content

otel k8s operator - auto instrumentation for java application doesn't inject traceid, spanid into logs #14350

@srujan63

Description

@srujan63

Describe the bug

we've deployed opentelemetry Kubernetes operator, auto instrumentation for java application. we've annotated java application pod to enable tracing and able to view traces in tempo. we've set OTEL_LOGS_INCLUDE_TRACE_CONTEXT=true to inject traceid into logs but traceid, spanid are either null or 0.

Steps to reproduce

1.Deploy opentelemetry Kubernetes operator, collector, auto instrumentation for java application.
2.Annotate java application pod to enable tracing.
3.Set OTEL_LOGS_INCLUDE_TRACE_CONTEXT=true in auto instrumentation for java.
4.Added trace_id=%mdc{trace_id} span_id=%mdc{span_id} and trace_id=%X{trace_id} span_id=%X{span_id} in log4j2.xml
5.View traceid, spanid in appliaction logs

Expected behavior

View traceid, spanid in appliaction logs

Actual behavior

traceid, spanid in appliaction logs are either null or 0
"2025-07-30 12:17:39 [main] INFO - trace_id= span_id= - spring.quartz.job-store-type ---jdbc---
"2025-07-30T12:17:39.731Z INFO 'spring.quartz.properties.org.quartz.jobStore.clusterCheckinInterval ---20000---' : 00000000000000000000000000000000 0000000000000000 [scopeInfo: :] {}

Javaagent or library instrumentation version

ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-java:1.33.6

Environment

JDK: Java 17.0.13
OS: Alpine Linux v3.21
Hibernate Validator 8.0.2.Final

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds author feedbackWaiting for additional feedback from the authorstale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions