-
Notifications
You must be signed in to change notification settings - Fork 419
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: Adding WithCustomTag
to various integrations
#1359
Changes from 18 commits
f01e184
f8c0559
97b98bd
ce2377c
44f1af4
b34c1ef
7791857
fa1a32d
be8d52d
d3e6207
52921ec
ba1c464
0cfc41f
3d28837
4f31706
4be53e6
7830af8
1e2d3f9
bbd4673
a4a48ed
37fef06
b4a432a
2847535
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -216,6 +216,12 @@ func (tp *traceParams) tryTrace(ctx context.Context, qtype queryType, query stri | |||
tracer.SpanType(ext.SpanTypeSQL), | ||||
tracer.StartTime(startTime), | ||||
) | ||||
if tp.cfg.tags != nil { | ||||
for key, tag := range tp.cfg.tags { | ||||
opts = append(opts, tracer.Tag(key, tag)) | ||||
} | ||||
} | ||||
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
if !math.IsNaN(tp.cfg.analyticsRate) { | ||||
opts = append(opts, tracer.Tag(ext.EventSampleRate, tp.cfg.analyticsRate)) | ||||
} | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,21 @@ import ( | |
"google.golang.org/grpc/status" | ||
) | ||
|
||
func addCustomTags(cfg *config, opts ...tracer.StartSpanOption) []tracer.StartSpanOption { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this is better suited as a method on // appendOpts creates a new set of StartSpanOptions by appending all options defined by configuration
// to opts.
func (cfg *config) appendOpts(opts ...tracer.StartSpanOption) []tracer.StartSpanOption { You can probably include There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addressed |
||
if cfg == nil || len(cfg.tags) == 0 { | ||
return opts | ||
} | ||
|
||
ret := make([]tracer.StartSpanOption, 0, len(cfg.tags)+len(opts)) | ||
for _, opt := range opts { | ||
ret = append(ret, opt) | ||
} | ||
for key, tag := range cfg.tags { | ||
ret = append(ret, tracer.Tag(key, tag)) | ||
} | ||
return ret | ||
} | ||
|
||
func startSpanFromContext( | ||
ctx context.Context, method, operation, service string, opts ...tracer.StartSpanOption, | ||
) (ddtrace.Span, context.Context) { | ||
|
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.
Why does it need a cast and a
_
? Or are you trying to test the type of the returned value, in which case ignore my comment.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.
the object from the channel is not consumed and what you suggested is preferred.