open-telemetry / open-telemetry/opentelemetry-java-instrumentation
Instrumentation of Kafka Clients: Add a Span or an attribute to the current span
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 1.2k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 228
Description
Describe the bug
Really I am not sur if it is a Bug, I am working on instrumentation of Kafka Produce/Receive Message following this article: https://opentelemetry.io/blog/2022/instrument-kafka-clients/
I want to add attribute to the current Span.
Steps to reproduce
I have test two methods to instrument kafka Client:
Interceptors: https://opentelemetry.io/blog/2022/instrument-kafka-clients/#using-the-interceptors
Wrapping: https://opentelemetry.io/blog/2022/instrument-kafka-clients/#wrapping-the-clients
in two cases I use this code add attributes to current Span:
Span span = Span.current();
span.setAttribute("messaging.user", "My User");
producer.send(new ProducerRecord<>(topic, payload));
My objectif is to add attribute to the current Span
This code is working fine when I make REST HTTP Request but not in case of Kafka CLient
What did you expect to see?
The attribute is added to the Span
What did you see instead?
Nothing is added
What version are you using?
org.apache.kafka
kafka-clients
3.5.1
io.opentelemetry.instrumentation
opentelemetry-kafka-clients-2.6
1.21.0-alpha
io.opentelemetry
opentelemetry-exporter-otlp
1.21.0
io.opentelemetry
opentelemetry-sdk-extension-autoconfigure
1.21.0-alpha
Environment
Compiler: JDK 17
OS: MAC OS
Runtime: JDK 17
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the Kafka interceptor and client-wrapping approaches described in the OpenTelemetry Kafka clients article, using the listed Kafka and OpenTelemetry versions. Inspect how Span.current() behaves around producer.send and determine whether the attribute is expected on the active span; done means a confirmed fix or a documented explanation with a focused reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kafka
- Domain
- distributed-systems, observability-sre, stream-processing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100