franz-go
franz-go copied to clipboard
kotel: optionally only use messaging.kafka.connects.count for connection metrics
This PR follows the discussion in https://github.com/twmb/franz-go/issues/670.
I added a new struct field, mergeConnectsMeter bool
that is manipulated by WithMergedConnectsMeter()
, to control whether to use one or 2 metrics to track connection successes/errors.
By default is set to false
to retain current behaviour.
When set to true
it disables the creation of messaging.kafka.connect_errors.count
metric and follows a different path in Meter.OnBrokerConnect
. There is some repetition as I wanted to avoid additional allocations when manipulating otel attributes (unfortunately Attribute Sets don't offer a way to add/remove elements from the set).
I added tests for the previous and new behaviour.
Let me know what you think, happy to adjust based on your feedback and thank you for your review!
@twmb I updated the PR to use attribute.Set
and fixed the documentation. I also set this ready for review, happy to know what's your opinion!