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
contrib/database/sql: add db service name tag and _dd.dbm_trace_injected span tag #1448
Conversation
d235547
to
23ec6e0
Compare
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.
Sorry for the delay on review here, just a few small comments overall looks fine to merge for this experimental feature
ddtrace/tracer/sqlcomment.go
Outdated
@@ -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 { |
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.
Any reason to create s
here? Perhaps just if ctx.span != nil
?
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.
Good catch. Updated ✅
ddtrace/tracer/sqlcomment.go
Outdated
@@ -141,6 +148,9 @@ func commentQuery(query string, tags map[string]string) string { | |||
if query == "" { | |||
return b.String() | |||
} | |||
if log.DebugEnabled() { |
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.
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
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.
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.
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.
Updated ✅
@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
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.
Looks good!
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.