open-telemetry / open-telemetry/opentelemetry-python-contrib
feat(kafka): add messaging.kafka.cluster.id to Kafka producer/consumer spans
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
Problem
Kafka spans (aiokafka, kafka-python, confluent-kafka) do not include messaging.kafka.cluster.id. When the same topic name exists across multiple clusters or environments, there is no way to distinguish which cluster a span came from.
Expected behavior
messaging.kafka.cluster.id (semconv) should be set on Kafka producer and consumer spans. It is a Recommended attribute in the Kafka messaging semantic conventions, so it is emitted by default (no opt-in flag), consistent with the other Recommended Kafka attributes these instrumentations already produce. The id is read from the client's own already-resolved metadata, so no extra broker connection is required.
Context
Part of a cross-language effort to add this attribute consistently across OTel instrumentations. See opentelemetry-java-instrumentation#18977 for the cross-language tracking issue.
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 reading the aiokafka, kafka-python, and confluent-kafka instrumentation entry points and the existing Recommended Kafka span attributes. Check how each client exposes already-resolved metadata, then verify producer and consumer spans include messaging.kafka.cluster.id by default without an extra broker connection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kafka, python
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100