Skip to content

Commit

Permalink
ddtrace/tracer.StartSpan: Use setMeta instead of SetTag (#1160)
Browse files Browse the repository at this point in the history
  • Loading branch information
evanj committed Mar 8, 2022
1 parent 5b114be commit c47da55
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
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 @@ -422,10 +422,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

0 comments on commit c47da55

Please sign in to comment.