fix(confluent-kafka): populate bootstrap.servers span attributes#4423
fix(confluent-kafka): populate bootstrap.servers span attributes#4423alliasgher wants to merge 5 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
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
left a comment
There was a problem hiding this comment.
Thanks for revisions!
|
This clashes with #4358 |
|
Thanks @xrmx — you're right, #4358 restructures Let me know if you'd prefer the opposite order. |
|
This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment. |
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: