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 db service name tag and _dd.dbm_trace_injected span tag #1448

Merged

Conversation

alexandre-normand
Copy link
Contributor

This follows-up on #1226 where we added sql comment tag injection support. As we're fleshing out the feature, we decided to add the db service name to the injected tags so that we can then have a link from collected query activity back to the APM database service. Also, to facilitate being able to filter traces where we've injected trace context in sql comments, we decided on adding a _dd.dbm_trace_injected tag. Given how the go tracer is the first language being implemented, feel free to comment on the naming which I can take back to refine the spec that isn't 100% final yet.

@alexandre-normand alexandre-normand requested a review from a team August 26, 2022 22:11
@alexandre-normand alexandre-normand added this to the 1.42.0 milestone Aug 26, 2022
@alexandre-normand alexandre-normand added the enhancement quick change/addition that does not need full team approval label Aug 26, 2022
@alexandre-normand alexandre-normand force-pushed the alex.normand/add-db-service-name-to-injected-sql-tags branch from d235547 to 23ec6e0 Compare August 30, 2022 17:29
Copy link
Contributor

@ajgajg1134 ajgajg1134 left a comment

Choose a reason for hiding this comment

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

Sorry for the delay on review here, just a few small comments overall looks fine to merge for this experimental feature

@@ -83,6 +86,9 @@ func (c *SQLCommentCarrier) Inject(spanCtx ddtrace.SpanContext) error {
if v, ok := ctx.meta(ext.Version); ok {
version = v
}
if s := ctx.span; s != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to create s here? Perhaps just if ctx.span != nil ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Updated ✅

@@ -141,6 +148,9 @@ func commentQuery(query string, tags map[string]string) string {
if query == "" {
return b.String()
}
if log.DebugEnabled() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need to check if DebugEnabled, you can just call log.Debug and it will not log if debug is disabled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I was wondering about that. The comment on that DebugEnabled said it was for things in "hot paths" to avoid the interface{} allocations. I wasn't sure if this would be considered a hot path or not. I'm fine to just switch to log.Debug.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated ✅

@alexandre-normand
Copy link
Contributor Author

@ajgajg1134 : I think I've addressed the comments. Thanks for the review 🙇 and let me know if there's anything else I should add/update prior to the merge.

…of github.com:DataDog/dd-trace-go into alex.normand/add-db-service-name-to-injected-sql-tags
Copy link
Contributor

@ajgajg1134 ajgajg1134 left a comment

Choose a reason for hiding this comment

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

Looks good!

@ajgajg1134 ajgajg1134 merged commit e611cb3 into main Sep 2, 2022
@ajgajg1134 ajgajg1134 deleted the alex.normand/add-db-service-name-to-injected-sql-tags branch September 2, 2022 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement quick change/addition that does not need full team approval
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants