@@ -21,7 +21,6 @@ import (
2121 "log"
2222 "strings"
2323
24- "go.opentelemetry.io/otel/attribute"
2524 otelcodes "go.opentelemetry.io/otel/codes"
2625 "go.opentelemetry.io/otel/trace"
2726 "google.golang.org/grpc"
@@ -84,10 +83,7 @@ func (h *clientTracingHandler) finishTrace(err error, ts trace.Span) {
8483// It creates a new outgoing carrier which serializes information about this
8584// span into gRPC Metadata, if TextMapPropagator is provided in the trace
8685// options. if TextMapPropagator is not provided, it returns the context as is.
87- //
88- // Note: The passed attemptInfo pointer (ai) is mutated in-place. Fields such as
89- // ai.traceSpan are updated directly. No new attemptInfo is returned.
90- func (h * clientTracingHandler ) traceTagRPC (ctx context.Context , ai * attemptInfo , nameResolutionDelayed bool ) context.Context {
86+ func (h * clientTracingHandler ) traceTagRPC (ctx context.Context , ai * attemptInfo , nameResolutionDelayed bool ) (context.Context , * attemptInfo ) {
9187 // Add a "Delayed name resolution complete" event to the call span
9288 // if there was name resolution delay. In case of multiple retry attempts,
9389 // ensure that event is added only once.
@@ -102,7 +98,7 @@ func (h *clientTracingHandler) traceTagRPC(ctx context.Context, ai *attemptInfo,
10298 carrier := otelinternaltracing .NewOutgoingCarrier (ctx )
10399 h .options .TraceOptions .TextMapPropagator .Inject (ctx , carrier )
104100 ai .traceSpan = span
105- return carrier .Context ()
101+ return carrier .Context (), ai
106102}
107103
108104// createCallTraceSpan creates a call span to put in the provided context using
@@ -125,12 +121,7 @@ func (h *clientTracingHandler) HandleConn(context.Context, stats.ConnStats) {}
125121// TagRPC implements per RPC attempt context management for traces.
126122func (h * clientTracingHandler ) TagRPC (ctx context.Context , info * stats.RPCTagInfo ) context.Context {
127123 ctx , ai := getOrCreateRPCAttemptInfo (ctx )
128- ci := getCallInfo (ctx )
129- if ci == nil {
130- logger .Error ("context passed into client side stats handler (TagRPC) has no call info" )
131- return ctx
132- }
133- ctx = h .traceTagRPC (ctx , ai , info .NameResolutionDelay )
124+ ctx , ai = h .traceTagRPC (ctx , ai , info .NameResolutionDelay )
134125 return setRPCInfo (ctx , & rpcInfo {ai : ai })
135126}
136127
@@ -141,15 +132,5 @@ func (h *clientTracingHandler) HandleRPC(ctx context.Context, rs stats.RPCStats)
141132 logger .Error ("ctx passed into client side tracing handler trace event handling has no client attempt data present" )
142133 return
143134 }
144-
145- // Client-specific Begin attributes.
146- if begin , ok := rs .(* stats.Begin ); ok {
147- ci := getCallInfo (ctx )
148- previousRPCAttempts := ci .previousRPCAttempts .Add (1 ) - 1
149- ri .ai .traceSpan .SetAttributes (
150- attribute .Int64 ("previous-rpc-attempts" , int64 (previousRPCAttempts )),
151- attribute .Bool ("transparent-retry" , begin .IsTransparentRetryAttempt ),
152- )
153- }
154135 populateSpan (rs , ri .ai )
155136}
0 commit comments