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

ddtrace/tracer.StartSpan: Use setMeta instead of SetTag #1160

Merged
merged 5 commits into from Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion contrib/google.golang.org/grpc/grpc_test.go
Expand Up @@ -799,7 +799,9 @@ func TestIgnoredMetadata(t *testing.T) {

func BenchmarkUnaryServerInterceptor(b *testing.B) {
// need to use the real tracer to get representative measurments
tracer.Start(tracer.WithLogger(log.DiscardLogger{}))
tracer.Start(tracer.WithLogger(log.DiscardLogger{}),
tracer.WithEnv("test"),
tracer.WithServiceVersion("0.1.2"))
defer tracer.Stop()

doNothingOKGRPCHandler := func(ctx context.Context, req interface{}) (interface{}, error) {
Expand Down Expand Up @@ -870,4 +872,12 @@ func BenchmarkUnaryServerInterceptor(b *testing.B) {
interceptor(ctx, "ignoredRequestValue", methodInfo, doNothingErrorGRPCHandler)
}
})
interceptorNoStack := UnaryServerInterceptor(NoDebugStack())
b.Run("error_no_metadata_no_stack", func(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
interceptorNoStack(ctx, "ignoredRequestValue", methodInfo, doNothingErrorGRPCHandler)
}
})
}
4 changes: 2 additions & 2 deletions ddtrace/tracer/tracer.go
Expand Up @@ -400,10 +400,10 @@ func (t *tracer) StartSpan(operationName string, options ...ddtrace.StartSpanOpt
delete(span.Metrics, keyMeasured)
}
if t.config.version != "" && span.Service == t.config.serviceName {
span.SetTag(ext.Version, t.config.version)
span.setMeta(ext.Version, t.config.version)
}
if t.config.env != "" {
span.SetTag(ext.Environment, t.config.env)
span.setMeta(ext.Environment, t.config.env)
}
if _, ok := span.context.samplingPriority(); !ok {
// if not already sampled or a brand new trace, sample it
Expand Down