Skip to content
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

contrib/database/sql: add in ddh, dddb propagation #2550

Merged
merged 2 commits into from
Feb 23, 2024

Conversation

tabgok
Copy link
Contributor

@tabgok tabgok commented Feb 9, 2024

What does this PR do?

This PR adds in the ddh and dddb peer service tags to SQL comments.

Motivation

This change allows the DBM product to propagate service name information which maps with the inferred entities/services used by APM.

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.
  • 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.

For Datadog employees:

  • If this PR touches code that handles credentials of any kind, such as Datadog API keys, I've requested a review from @DataDog/security-design-and-guidance.
  • This PR doesn't touch any of that.

Unsure? Have a question? Request a review!

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

pr-commenter bot commented Feb 9, 2024

Benchmarks

Benchmark execution time: 2024-02-22 20:03:14

Comparing candidate commit b51d551 in PR branch teague.bick/AIT-9706/dbm-peer-service-tags with baseline commit 1dfe613 in branch main.

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

Copy link
Contributor

@rarguelloF rarguelloF left a comment

Choose a reason for hiding this comment

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

Nice work, but I think we need a slightly different approach because of the issue mentioned in one of the comments (it will only work when there's a parent span + the parent span is modified).

The code in this integration is a little bit tricky, since it starts the span after the actual query is executed and the DBM comments are injected (there is a comment in the injectComments function explaining the rationale behind this).

For this reason, probably the simplest approach to achieve this is:

  • Update the tracer.SQLCommentCarrier to include 2 new fields: PeerHostname and PeerDBName and use those for the comment injection.
  • Update injectComments to set these 2 new fields accessing the corresponding tags from tc.meta.

Please let me know if you agree and/or wanna discuss the approach in more detail! 🙇

.vscode/launch.json Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
docker-compose.override.yaml Outdated Show resolved Hide resolved
ddtrace/tracer/sqlcomment_test.go Outdated Show resolved Hide resolved
ddtrace/tracer/sqlcomment.go Outdated Show resolved Hide resolved
ddtrace/tracer/sqlcomment.go Outdated Show resolved Hide resolved
contrib/database/sql/conn.go Outdated Show resolved Hide resolved
contrib/database/sql/internal/dsn.go Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
@tabgok tabgok force-pushed the teague.bick/AIT-9706/dbm-peer-service-tags branch from d6d365a to 17cb8aa Compare February 12, 2024 23:08
@tabgok tabgok force-pushed the teague.bick/AIT-9706/dbm-peer-service-tags branch from 92d604b to 822a758 Compare February 13, 2024 17:40
@tabgok tabgok self-assigned this Feb 13, 2024
contrib/database/sql/internal/dsn.go Outdated Show resolved Hide resolved
contrib/database/sql/propagation_test.go Outdated Show resolved Hide resolved
ddtrace/tracer/sqlcomment_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@rarguelloF rarguelloF left a comment

Choose a reason for hiding this comment

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

Looking great! Just a small change in the newly introduced ParseDSN logic changes and should be good to go!

Copy link
Contributor

@rarguelloF rarguelloF left a comment

Choose a reason for hiding this comment

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

One last comment I missed in the previous review, which I noticed from the failed tests in the CI.

ddtrace/tracer/sqlcomment_test.go Outdated Show resolved Hide resolved
@tabgok tabgok force-pushed the teague.bick/AIT-9706/dbm-peer-service-tags branch from 5456182 to 5274823 Compare February 14, 2024 12:41
@tabgok tabgok force-pushed the teague.bick/AIT-9706/dbm-peer-service-tags branch from c44de59 to 134e57c Compare February 16, 2024 17:13
contrib/database/sql/propagation_test.go Outdated Show resolved Hide resolved
ddtrace/tracer/sqlcomment_test.go Outdated Show resolved Hide resolved
ddtrace/tracer/sqlcomment.go Outdated Show resolved Hide resolved
contrib/database/sql/propagation_test.go Outdated Show resolved Hide resolved
contrib/database/sql/propagation_test.go Outdated Show resolved Hide resolved
contrib/database/sql/internal/dsn.go Outdated Show resolved Hide resolved
@tabgok tabgok force-pushed the teague.bick/AIT-9706/dbm-peer-service-tags branch 2 times, most recently from 44ec0de to 60ec21b Compare February 21, 2024 12:55
@tabgok tabgok force-pushed the teague.bick/AIT-9706/dbm-peer-service-tags branch from 60ec21b to 2138e10 Compare February 21, 2024 12:56
@tabgok tabgok marked this pull request as ready for review February 21, 2024 12:56
@tabgok tabgok requested review from a team as code owners February 21, 2024 12:56
contrib/database/sql/internal/dsn.go Outdated Show resolved Hide resolved
contrib/database/sql/internal/dsn.go Outdated Show resolved Hide resolved
ddtrace/tracer/sqlcomment.go Outdated Show resolved Hide resolved
ddtrace/tracer/sqlcomment.go Outdated Show resolved Hide resolved
@tabgok
Copy link
Contributor Author

tabgok commented Feb 22, 2024

/merge

@dd-devflow
Copy link

dd-devflow bot commented Feb 22, 2024

❌ MergeQueue

You are not allowed to use the merge queue towards main.

If you need support, contact us on Slack #ci-interfaces with those details!

@rarguelloF rarguelloF self-requested a review February 23, 2024 10:22
@tabgok
Copy link
Contributor Author

tabgok commented Feb 23, 2024

/merge

@dd-devflow
Copy link

dd-devflow bot commented Feb 23, 2024

❌ MergeQueue

You are not allowed to use the merge queue towards main.

If you need support, contact us on Slack #ci-interfaces with those details!

@rarguelloF
Copy link
Contributor

/merge

@dd-devflow
Copy link

dd-devflow bot commented Feb 23, 2024

🚂 MergeQueue

Pull request added to the queue.

This build is going to start soon! (estimated merge in less than 58s)

Use /merge -c to cancel this operation!

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.

4 participants