-
Notifications
You must be signed in to change notification settings - Fork 279
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
Apply configured service name mapping to DBM-injected dddbs
#7064
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Would it be possible to add tests? |
yes I'll look into it. For now, it seems there might be some tests failing, that I cannot reproduce locally :( |
amarziali
reviewed
Jun 5, 2024
dd-java-agent/instrumentation/jdbc/src/test/groovy/DBMInjectionForkedTest.groovy
Outdated
Show resolved
Hide resolved
amarziali
reviewed
Jun 5, 2024
dd-java-agent/instrumentation/jdbc/src/test/groovy/DBMInjectionForkedTest.groovy
Outdated
Show resolved
Hide resolved
amarziali
reviewed
Jun 5, 2024
...src/main/java/datadog/trace/instrumentation/jdbc/DBMCompatibleConnectionInstrumentation.java
Outdated
Show resolved
Hide resolved
amarziali
approved these changes
Jun 5, 2024
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.
LGTM. I left some suggestions
dddbs
dddbs
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What Does This Do
The injected dddbs tag should respect service mapping.
For single statements, we create the span and inject the comment in the same instrumentation, so everything is well (code)
However, for prepared statements, it's more complicated, because it happens in 2 steps:
Thus, we don't have the span yet when we do the injection for prepared statements.
Service mapping logic was only applied when a service name is set in a span:
dd-trace-java/dd-trace-core/src/main/java/datadog/trace/core/DDSpanContext.java
Lines 398 to 401 in ad66ae8
so if we get a service name not from a span, the mapping wouldn't be applied to it.
To fix this, I'm repeating the logic that is found here:
dd-trace-java/dd-trace-core/src/main/java/datadog/trace/core/PendingTrace.java
Line 173 in 0779b79
@mcculls helped with the code to retrieve the current trace's config snapshot.
Jira ticket: APMS-12191
fixes #7034