Skip to content

Commit

Permalink
Move call to inject context into SQL Comments Further Down
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandre-normand committed Mar 30, 2022
1 parent f844cc0 commit 07f4596
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions contrib/database/sql/conn.go
Expand Up @@ -251,11 +251,6 @@ func (tp *traceParams) tryStartTrace(ctx context.Context, qtype queryType, query
resource := string(qtype)
if query != "" {
resource = query
err := tracer.Inject(span.Context(), sqlCommentCarrier)
if err != nil {
// this should never happen
fmt.Fprintf(os.Stderr, "contrib/database/sql: failed to inject query comments: %v\n", err)
}
}
span.SetTag("sql.query_type", string(qtype))
span.SetTag(ext.ResourceName, resource)
Expand All @@ -268,5 +263,11 @@ func (tp *traceParams) tryStartTrace(ctx context.Context, qtype queryType, query
}
}

err = tracer.Inject(span.Context(), sqlCommentCarrier)
if err != nil {
// this should never happen
fmt.Fprintf(os.Stderr, "contrib/database/sql: failed to inject query comments: %v\n", err)
}

return span
}

0 comments on commit 07f4596

Please sign in to comment.