Skip to content

Conversation

@hannahkm
Copy link
Contributor

@hannahkm hannahkm commented Nov 20, 2025

What does this PR do?

Propagate tags from existing, registered configs to new drivers. Ensures that spans generated from database/sql contains custom tags that are added at registration.

Motivation

Spans were missing custom tags from registered configs.

Closes #4135

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!

@github-actions github-actions bot added the apm:ecosystem contrib/* related feature requests or bugs label Nov 20, 2025
@pr-commenter
Copy link

pr-commenter bot commented Nov 20, 2025

Benchmarks

Benchmark execution time: 2025-11-20 16:41:29

Comparing candidate commit 43ac3d0 in PR branch hannahkm/fix-db-sql-tags with baseline commit 1ed7e54 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 18 metrics, 0 unstable metrics.

@hannahkm hannahkm marked this pull request as ready for review November 20, 2025 22:05
@hannahkm hannahkm requested review from a team as code owners November 20, 2025 22:05
Copy link
Contributor

@mtoffl01 mtoffl01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks for doing this

Comment on lines +161 to +166
if cfg.tags == nil {
cfg.tags = make(map[string]interface{})
}
for k, v := range rc.tags {
cfg.tags[k] = v
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how much this matters for Go, but a quick optimization here might be to only initialize cfg.tags to an empty map IF we have rc.tags to copy over. So, if len(rc.tags) > 0.

This depends on whether we expect cfg.tags to already be initialized later on, when we read from it, though.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: contrib/database/sql does not read tags from registered driver

3 participants