Replies: 1 comment 5 replies
-
To have trace and span id available in MDC you must have an active trace. For kafka this means that you need instrumentation that restores context from context propagation header added to a kafka message. Looking at your pom fragment you don't seem to be using a kafka instrumentation so not having trace and span id is expected. Even if you use kafka instrumentation trace and span id will only be available when the context is restored, for example when using https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/spring/spring-kafka-2.7 you could expect to observe the restored context while inside a |
Beta Was this translation helpful? Give feedback.
-
Hi,
Below are the config i have done for my application, trace and span id generated also traceparent added in kafka message header as - 00-9e94c3668945e351de9bcce36fa50b77-6cf5599c9aa1bb9e-01
pom.xml
log4j2.xml
2024-09-23T15:03:59.466+05:30 trace_id= span_id= trace_flags= INFO 57396 --- [otel_demo] [nio-8080-exec-1] o.a.k.c.t.i.KafkaMetricsCollector : initializing Kafka metrics collector
2024-09-23T09:33:59.466Z INFO 'initializing Kafka metrics collector' : 9e94c3668945e351de9bcce36fa50b77 0a153e372d34851d [scopeInfo: org.apache.kafka.common.telemetry.internals.KafkaMetricsCollector:] {}
2024-09-23T15:03:59.520+05:30 trace_id= span_id= trace_flags= INFO 57396 --- [otel_demo] [nio-8080-exec-1] o.a.k.clients.producer.KafkaProducer : [Producer clientId=otel_demo-producer-1] Instantiated an idempotent producer.
2024-09-23T09:33:59.52Z INFO '[Producer clientId=otel_demo-producer-1] Instantiated an idempotent producer.' : 9e94c3668945e351de9bcce36fa50b77 0a153e372d34851d [scopeInfo: org.apache.kafka.clients.producer.KafkaProducer:] {}
2024-09-23T15:03:59.547+05:30 trace_id= span_id= trace_flags= INFO 57396 --- [otel_demo] [nio-8080-exec-1] o.a.kafka.common.utils.AppInfoParser : Kafka version: 3.7.1
2024-09-23T09:33:59.547Z INFO 'Kafka version: 3.7.1' : 9e94c3668945e351de9bcce36fa50b77 0a153e372d34851d [scopeInfo: org.apache.kafka.common.utils.AppInfoParser:] {}
2024-09-23T15:03:59.547+05:30 trace_id= span_id= trace_flags= INFO 57396 --- [otel_demo] [nio-8080-exec-1] o.a.kafka.common.utils.AppInfoParser : Kafka commitId: e2494e6ffb89f828
2024-09-23T09:33:59.547Z INFO 'Kafka commitId: e2494e6ffb89f828' : 9e94c3668945e351de9bcce36fa50b77 0a153e372d34851d [scopeInfo: org.apache.kafka.common.utils.AppInfoParser:] {}
2024-09-23T15:03:59.547+05:30 trace_id= span_id= trace_flags= INFO 57396 --- [otel_demo] [nio-8080-exec-1] o.a.kafka.common.utils.AppInfoParser : Kafka startTimeMs: 1727084039545
2024-09-23T09:33:59.547Z INFO 'Kafka startTimeMs: 1727084039545' : 9e94c3668945e351de9bcce36fa50b77 0a153e372d34851d [scopeInfo: org.apache.kafka.common.utils.AppInfoParser:] {}
2024-09-23T15:03:59.724+05:30 trace_id= span_id= trace_flags= INFO 57396 --- [otel_demo] [demo-producer-1] org.apache.kafka.clients.Metadata : [Producer clientId=otel_demo-producer-1] Cluster ID: lT2QuuCARkKuBzZfw2ueKQ
2024-09-23T09:33:59.724Z INFO '[Producer clientId=otel_demo-producer-1] Cluster ID: lT2QuuCARkKuBzZfw2ueKQ' : 00000000000000000000000000000000 0000000000000000 [scopeInfo: org.apache.kafka.clients.Metadata:] {}
2024-09-23T15:03:59.725+05:30 trace_id= span_id= trace_flags= INFO 57396 --- [otel_demo] [demo-producer-1] o.a.k.c.p.internals.TransactionManager : [Producer clientId=otel_demo-producer-1] ProducerId set to 29 with epoch 0```
Set environment variable :
export OTEL_METRICS_EXPORTER=none
export OTEL_LOGS_EXPORTER=none
export OTEL_TRACES_EXPORTER=none
Running application with - jar - java -Dotel.metrics.exporter=none -jar ./target/otel-demo-0.0.1-SNAPSHOT.jar
I have also tried with logback from reference - https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/logback/logback-mdc-1.0/library
still the same.
Beta Was this translation helpful? Give feedback.
All reactions