Skip to content

feat(instrumentation-kafkajs): record messaging.consumer.group.name on consumer spans and metrics - #3952

Open
leo-fresha wants to merge 1 commit into
open-telemetry:mainfrom
leo-fresha:feat/kafkajs-consumer-group
Open

leo-fresha wants to merge 1 commit into
open-telemetry:mainfrom
leo-fresha:feat/kafkajs-consumer-group

Conversation

@leo-fresha

@leo-fresha leo-fresha commented Dec 1, 2026 •

Copy link
Copy Markdown

Which problem is this PR solving?

The Kafka semantic conventions make messaging.consumer.group.name conditionally required on consumer spans and on the messaging.process.duration and messaging.client.consumed.messages metrics, whenever there is a consumer group. The instrumentation doesn't record it, so a span or metric can't be attributed to the group that consumed the message, and groups reading the same topic can't be told apart.

Short description of the changes

  • The consumer patch reads groupId from the config passed to kafka.consumer() and passes it to the eachMessage and eachBatch patches, in the same way the client is passed for messaging.kafka.cluster.id (feat(instrumentation-kafkajs): add messaging.kafka.cluster.id span attribute #3577).
  • process spans, the eachBatch poll span, and the two consumer metrics record it as messaging.consumer.group.name.
  • The README lists the attribute.

This change was written with the help of Claude Opus 5.5 and reviewed by me before opening.

@leo-fresha
leo-fresha requested a review from a team as a code owner December 1, 2026 14:57
@linux-foundation-easycla

linux-foundation-easycla Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

CLA Not Signed

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Welcome, contributor! Thank you for your contribution to opentelemetry-js-contrib.

Important reminders:

  • Read our Contributing Guidelines.
  • Sign the CLA if you haven't already.
  • Follow the OpenTelemetry Generative AI policy: disclose any AI use in your contribution, and communicate (PR descriptions, review replies) in your own words rather than AI-generated text.
  • Give reviewers at least a few days before pinging them for feedback.
  • If you need help with general setup, development process, or contributor etiquette, ask in #opentelemetry-new-contributors.

@opentelemetry-pr-dashboard

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-12-01 14:58 UTC

Investigate required status check failures.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Should this be with reviewers? Comment /dashboard route:reviewers to route it to them.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

…n consumer spans and metrics

The Kafka semantic conventions make messaging.consumer.group.name
conditionally required on consumer spans and on the process duration and
consumed messages metrics. The consumer patch now reads groupId from the
config passed to kafka.consumer() and records it on the spans and metrics
of eachMessage and eachBatch.

Assisted-by: Claude Opus 5.5
@leo-fresha
leo-fresha force-pushed the feat/kafkajs-consumer-group branch from a7e1f25 to 08f372a Compare December 1, 2026 15:14

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants