@@ -20,22 +20,24 @@ import (
20
20
"context"
21
21
"strings"
22
22
23
- "go.opentelemetry.io/otel"
24
23
"go.opentelemetry.io/otel/trace"
24
+ "google.golang.org/grpc"
25
25
otelinternaltracing "google.golang.org/grpc/stats/opentelemetry/internal/tracing"
26
26
)
27
27
28
+ const tracerName = "grpc-go"
29
+
28
30
// traceTagRPC populates provided context with a new span using the
29
31
// TextMapPropagator supplied in trace options and internal itracing.carrier.
30
32
// It creates a new outgoing carrier which serializes information about this
31
33
// span into gRPC Metadata, if TextMapPropagator is provided in the trace
32
34
// options. if TextMapPropagator is not provided, it returns the context as is.
33
35
func (h * clientStatsHandler ) traceTagRPC (ctx context.Context , ai * attemptInfo ) (context.Context , * attemptInfo ) {
34
36
mn := "Attempt." + strings .Replace (ai .method , "/" , "." , - 1 )
35
- tracer := otel . Tracer (" grpc-open-telemetry" )
37
+ tracer := h . options . TraceOptions . TracerProvider . Tracer (tracerName , trace . WithInstrumentationVersion ( grpc . Version ) )
36
38
ctx , span := tracer .Start (ctx , mn )
37
39
carrier := otelinternaltracing .NewOutgoingCarrier (ctx )
38
- otel . GetTextMapPropagator () .Inject (ctx , carrier )
40
+ h . options . TraceOptions . TextMapPropagator .Inject (ctx , carrier )
39
41
ai .traceSpan = span
40
42
return carrier .Context (), ai
41
43
}
@@ -48,7 +50,7 @@ func (h *clientStatsHandler) createCallTraceSpan(ctx context.Context, method str
48
50
return ctx , nil
49
51
}
50
52
mn := strings .Replace (removeLeadingSlash (method ), "/" , "." , - 1 )
51
- tracer := otel . Tracer (" grpc-open-telemetry" )
53
+ tracer := h . options . TraceOptions . TracerProvider . Tracer (tracerName , trace . WithInstrumentationVersion ( grpc . Version ) )
52
54
ctx , span := tracer .Start (ctx , mn , trace .WithSpanKind (trace .SpanKindClient ))
53
55
return ctx , span
54
56
}
0 commit comments