-
Notifications
You must be signed in to change notification settings - Fork 484
feat(contrib/sarama): option to add custom consumer/producer span options #3993
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
base: main
Are you sure you want to change the base?
Conversation
Discussing this with colleagues we also came up with the idea of changing this to a more generic |
This sounds more future-proof TBH. |
Cool, thanks for the feedback @kakkoyun. I'm on vacation for the next few weeks so not sure when I'll be able to update this, but I'll try to make some time to do so. |
6700372
to
f57982f
Compare
f57982f
to
0debdab
Compare
@kakkoyun Could you please let me know if there are any additional changes needed, or if the implemented code looks good to you? |
} | ||
|
||
// WithCustomConsumerSpanOptions enables calling a callback func to add custom span options on wrapped consumers. | ||
func WithCustomConsumerSpanOptions(f CustomConsumerSpanOptsFunc) OptionFn { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func WithCustomConsumerSpanOptions(f CustomConsumerSpanOptsFunc) OptionFn { | |
func WithConsumerCustomTag(tag string, tagFn func(msg *sarama.ConsumerMessage) any) OptionFn { |
As the conversation in the PR, lets keep it scoped to custom tags.
Also let's try to follow the same format of the the WithCustomTag
option in other integrations, where the first argument is the tag name and the second is the function to compute the value.
type CustomConsumerSpanOptsFunc func(msg *sarama.ConsumerMessage) []tracer.StartSpanOption | ||
type CustomProducerSpanOptsFunc func(msg *sarama.ProducerMessage) []tracer.StartSpanOption |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type CustomConsumerSpanOptsFunc func(msg *sarama.ConsumerMessage) []tracer.StartSpanOption | |
type CustomProducerSpanOptsFunc func(msg *sarama.ProducerMessage) []tracer.StartSpanOption |
these aliases shouldn't be necessary
customConsumerSpanOptionsFunc CustomConsumerSpanOptsFunc | ||
customProducerSpanOptionsFunc CustomProducerSpanOptsFunc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
customConsumerSpanOptionsFunc CustomConsumerSpanOptsFunc | |
customProducerSpanOptionsFunc CustomProducerSpanOptsFunc | |
consumerCustomTags map[string]func(msg *sarama.ConsumerMessage) any | |
producerCustomTags map[string]func(msg *sarama.ProducerMessage) any |
} | ||
|
||
// WithCustomProducerSpanOptions enables calling a callback func to add custom span options on wrapped producers. | ||
func WithCustomProducerSpanOptions(f CustomProducerSpanOptsFunc) OptionFn { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func WithCustomProducerSpanOptions(f CustomProducerSpanOptsFunc) OptionFn { | |
func WithProducerCustomTag(tag string, tagFn func(msg *sarama.ProducerMessage) any) OptionFn { |
What does this PR do?
Add
WithCustomConsumerSpanOptions
andWithCustomProducerSpanOptions
options to enable customizing spans generated by wrapped consumers and producers.Motivation
Including extra information (e.g. Kafka message keys) as tags on spans can greatly enhance observability, enabling users to filter, group, and analyze traces based on specific message properties. This improves debugging capabilities and provides a clearer understanding of message flow within Kafka-based systems.
Reviewer's Checklist
./scripts/lint.sh
locally.Unsure? Have a question? Request a review!