fix(confluent-kafka): populate bootstrap.servers span attributes#4423
Open
alliasgher wants to merge 4 commits intoopen-telemetry:mainfrom
Open
fix(confluent-kafka): populate bootstrap.servers span attributes#4423alliasgher wants to merge 4 commits intoopen-telemetry:mainfrom
alliasgher wants to merge 4 commits intoopen-telemetry:mainfrom
Conversation
KafkaPropertiesExtractor.extract_bootstrap_servers was defined but
never called, so confluent-kafka spans were missing messaging.url,
server.address, and server.port even though the extraction helper
existed for it.
- Capture the config dict in AutoInstrumentedProducer/Consumer and
surface it on the Proxied{Producer,Consumer} wrappers.
- extract_bootstrap_servers now accepts both the "bootstrap.servers"
dotted key (confluent-kafka standard) and "bootstrap_servers", and
safely handles list-valued configs and instances without a config
attribute.
- wrap_produce / wrap_poll / wrap_consume pull the config and pass
it through _enrich_span, which sets messaging.url, server.address,
and server.port (parsing host:port from the first broker).
Closes open-telemetry#4104
Signed-off-by: alliasgher <alliasgher123@gmail.com>
…link Signed-off-by: alliasgher <alliasgher123@gmail.com>
366b445 to
73dd510
Compare
MikeGoldsmith
approved these changes
Apr 15, 2026
Member
MikeGoldsmith
left a comment
There was a problem hiding this comment.
Looks good, just noticed one thing that wasn't changed here but very close and would be good to fix. We can do in a separate PR if you prefer.
The second _enrich_span call in wrap_produce also runs inside a producer span but used RECEIVE. Align with the first path and with the semantic conventions. Signed-off-by: Ali <alliasgher123@gmail.com>
tammy-baylis-swi
approved these changes
Apr 15, 2026
Contributor
tammy-baylis-swi
left a comment
There was a problem hiding this comment.
Thanks for revisions!
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
KafkaPropertiesExtractor.extract_bootstrap_serverswas defined inutils.pybut was never actually invoked anywhere in the instrumentation, so confluent-kafka spans were missingmessaging.url,server.address, andserver.porteven though the extraction helper existed for it. This PR wires the helper up end-to-end.Changes:
AutoInstrumentedProducer/AutoInstrumentedConsumernow capture the config dict passed to their constructor, andProxiedProducer/ProxiedConsumersurface the wrapped instance's config if one is present.extract_bootstrap_serversaccepts both"bootstrap.servers"(the dotted key confluent-kafka uses) and"bootstrap_servers", tolerates list-valued configs, and returnsNonewhen no config is attached instead of raisingAttributeError.wrap_produce/wrap_poll/wrap_consumenow pass the bootstrap servers through to_enrich_span, which setsmessaging.url,server.address, andserver.port(parsed from the first broker in the list).Producer spans and consumer
<topic> processspans both get the new attributes.Fixes #4104
Type of change
How Has This Been Tested?
test_producer_sets_bootstrap_servers_attributesandtest_consumer_sets_bootstrap_servers_attributesthat exercise the proxy path end-to-end and assert the new attributes.test_instrumentation.pysuite (16 tests pass).Does This PR Require a Contrib Repo Change?
Checklist: