Skip to content

feat(instrumentation-kafkajs): update semantic conventions #2752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

brianphillips
Copy link
Contributor

@brianphillips brianphillips commented Mar 12, 2025

Which problem is this PR solving?

Semantic conventions used in @opentelemetry/instrumentation-kafkajs are quite outdated.

Short description of the changes

  • Updated @opentelemetry/semantic-conventions in @opentelemetry/instrumentation-kafkajs to version 1.30.0.
  • Updated code for span creation to use new attributes/values per semantic conventions.
  • Added various metrics per the semantic conventions for messaging systems
  • Added tests for the above

@brianphillips brianphillips requested a review from a team as a code owner March 12, 2025 19:22
@github-actions github-actions bot requested a review from seemk March 12, 2025 19:25
Copy link

codecov bot commented Mar 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.44%. Comparing base (25b38f3) to head (ba4b39b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2752      +/-   ##
==========================================
+ Coverage   89.20%   89.44%   +0.24%     
==========================================
  Files         168      172       +4     
  Lines        8076     8310     +234     
  Branches     1547     1591      +44     
==========================================
+ Hits         7204     7433     +229     
- Misses        872      877       +5     
Files with missing lines Coverage Δ
...ode/instrumentation-kafkajs/src/instrumentation.ts 97.56% <100.00%> (ø)
...node/instrumentation-kafkajs/src/internal-types.ts 100.00% <100.00%> (ø)
...lugins/node/instrumentation-kafkajs/src/semconv.ts 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@brianphillips brianphillips force-pushed the kafkajs-semantic-conv-upgrade branch from bca0213 to e092462 Compare March 14, 2025 02:00
Comment on lines +445 to +457
spans.push(
instrumentation._startConsumerSpan({
topic: payload.batch.topic,
message,
operationType: MESSAGING_OPERATION_TYPE_VALUE_PROCESS,
link: origSpanLink,
attributes: {
[ATTR_MESSAGING_DESTINATION_PARTITION_ID]: String(
payload.batch.partition
),
},
})
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't new code but it feels a little bit wrong when compared to the examples in the semantic conventions doc (this one, specifically). All of these process spans for each message will have the same start/end times as the batch itself and I'm not sure that's helpful or intuitive. But for now, I'm leaving that design choice alone and just adding the corresponding metric that the semantic convention requires for all process spans.

Copy link
Contributor

@seemk seemk Mar 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this might be out of scope for this PR. Think creating a single receive span with messaging.batch.message_count attribute would be fine and then add the message offset, parent span context as links, not as new spans. (Trying this out with SQS: #2345)

@brianphillips brianphillips force-pushed the kafkajs-semantic-conv-upgrade branch from e092462 to 00e0787 Compare March 14, 2025 12:13
@pichlermarc pichlermarc added the has:owner-approval Approved by Component Owner label Mar 19, 2025
@pichlermarc pichlermarc merged commit 407f615 into open-telemetry:main Mar 24, 2025
10 checks passed
@dyladan dyladan mentioned this pull request Mar 24, 2025
@brianphillips brianphillips deleted the kafkajs-semantic-conv-upgrade branch March 24, 2025 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has:owner-approval Approved by Component Owner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants