Skip to content

@opentelemetry/instrumentation-kafkajs: Add brokerAddress attribute support (requires narrowing supported versions) #2770

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

Open
1 of 2 tasks
AvihuHenya opened this issue Mar 24, 2025 · 4 comments

Comments

@AvihuHenya
Copy link
Contributor

AvihuHenya commented Mar 24, 2025

  • This only affects the JavaScript OpenTelemetry library
  • This may affect other libraries, but I would like to get opinions here first

I’ve been working on improving the kafkajs instrumentation by adding support for capturing the Kafka broker address as an attribute.
The Kafka broker address can be extracted from the brokerAddress property in kafkajs — however, this property only exists from kafkajs v1.4.1 onwards.

Current situation

  • The current instrumentation supports kafkajs >=0.3.0 <3.
  • Adding server.address would be a valuable enhancement, but would require narrowing the supported range to >=1.4.1 <3.

Proposed change

  • Update the instrumentation to add brokerAddress (ATTR_SERVER_ADDRESS) (for producer spans at this time).
  • Adjust the supported versions in the instrumentation to >=1.4.1 <3.

Why this should be safe

  • Looking at kafkajs version download statistics on npm, versions below 1.4.1 account for a very small percentage of downloads.
  • This means the impact of narrowing the supported range will be minimal and unlikely to affect most users.

Benefits

  • Aligns with OpenTelemetry semantic conventions for messaging systems.
  • Provides more granular and valuable telemetry data for tracing Kafka communications.

Questions for maintainers
Are you open to narrowing the supported range as part of this enhancement?
If yes, would you like me to open a PR with the changes and the version range adjustment?

My current progress
I already have a working local implementation that:

  • Patches the appropriate kafkajs internals
  • Adds the broker address as a span attribute
  • Handles injection and context propagation properly

Happy to polish it and contribute if this direction makes sense!

@AvihuHenya AvihuHenya changed the title @opentelemetry/instrumentation-kafkajs: Add server.address attribute support (requires narrowing supported versions) @opentelemetry/instrumentation-kafkajs: Add brokerAddress attribute support (requires narrowing supported versions) Mar 24, 2025
@pichlermarc
Copy link
Member

We talked about this in today's SIG meeting.
@seemk wdyt about dropping support for kafkajs < 1.4.1?

@seemk
Copy link
Contributor

seemk commented Mar 26, 2025

We talked about this in today's SIG meeting. @seemk wdyt about dropping support for kafkajs < 1.4.1?

Sure, that seems quite ancient

@blumamir
Copy link
Member

according to npm, the relevant versions which will be affected are very few 7 years old releases with 188-311 downloads, compared to the recent version with 1,126,007 downloads.

I find it hard to believe anyone that is instrumenting with opentelemetry and using those very old version, so I support this change.

disclaimer: I am working with @AvihuHenya and am personally interested in seeing this enhancement move forward.

@blumamir
Copy link
Member

We talked about this in today's SIG meeting. @seemk wdyt about dropping support for kafkajs < 1.4.1?

Sure, that seems quite ancient

great, thanks @seemk

@AvihuHenya I will assign this issue to you so you can work on a PR to make this change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants