Skip to content

Conversation

@fabiomargarido
Copy link
Contributor

@fabiomargarido fabiomargarido commented Sep 25, 2025

What does this PR do?

Add WithConsumerCustomTag and WithProducerCustomTag options to enable adding custom tags to 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

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running ./scripts/lint.sh locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.

Unsure? Have a question? Request a review!

@fabiomargarido fabiomargarido requested review from a team as code owners September 25, 2025 14:17
@fabiomargarido
Copy link
Contributor Author

fabiomargarido commented Sep 30, 2025

Discussing this with colleagues we also came up with the idea of changing this to a more generic WithCustomTags which takes a func that returns a slice of tags to be added to the span. I can change it to that if you think it makes more sense.

@kakkoyun
Copy link
Member

kakkoyun commented Oct 2, 2025

Discussing this with colleagues we also came up with the idea of changing this to a more generic WithCustomTags which takes a func that returns a slice of tags to be added to the span. I can change it to that if you think it makes more sense.

This sounds more future-proof TBH.

@fabiomargarido
Copy link
Contributor Author

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.

@rarguelloF rarguelloF added the apm:ecosystem contrib/* related feature requests or bugs label Oct 3, 2025
@fabiomargarido fabiomargarido changed the title feat(contrib/sarama): add option to tag spans with kafka key feat(contrib/sarama): option to add custom consumer/producer span options Oct 3, 2025
@gubtos
Copy link

gubtos commented Oct 8, 2025

@kakkoyun Could you please let me know if there are any additional changes needed, or if the implemented code looks good to you?

@fabiomargarido
Copy link
Contributor Author

@rarguelloF I have pushed the requested changes, can you please check it again? Thanks

@fabiomargarido fabiomargarido changed the title feat(contrib/sarama): option to add custom consumer/producer span options feat(contrib/sarama): option to add custom consumer/producer span tags Oct 28, 2025
@fabiomargarido
Copy link
Contributor Author

@rarguelloF anything missing here?

@rarguelloF
Copy link
Contributor

/merge

@dd-devflow-routing-codex
Copy link

dd-devflow-routing-codex bot commented Nov 3, 2025

View all feedbacks in Devflow UI.

2025-11-03 16:38:14 UTC ℹ️ Start processing command /merge


2025-11-03 16:38:20 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 18m (p90).


2025-11-03 16:52:10 UTCMergeQueue: The checks failed on this merge request

Tests failed on this commit 4222043:

What to do next?

  • Investigate the failures and when ready, re-add your pull request to the queue!
  • If your PR checks are green, try to rebase/merge. It might be because the CI run is a bit old.
  • Any question, go check the FAQ.

@rarguelloF
Copy link
Contributor

@fabiomargarido sorry I think it is a flaky test, it should be merged soon

@rarguelloF
Copy link
Contributor

/merge

@dd-devflow-routing-codex
Copy link

dd-devflow-routing-codex bot commented Nov 3, 2025

View all feedbacks in Devflow UI.

2025-11-03 17:02:19 UTC ℹ️ Start processing command /merge


2025-11-03 17:02:26 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2025-11-03 17:25:32 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in main is approximately 18m (p90).


2025-11-03 17:41:27 UTC ℹ️ MergeQueue: This merge request was merged

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

Labels

apm:ecosystem contrib/* related feature requests or bugs mergequeue-status: done

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants