@@ -21,7 +21,6 @@ import (
21
21
"log"
22
22
"strings"
23
23
24
- "go.opentelemetry.io/otel/attribute"
25
24
otelcodes "go.opentelemetry.io/otel/codes"
26
25
"go.opentelemetry.io/otel/trace"
27
26
"google.golang.org/grpc"
@@ -84,10 +83,7 @@ func (h *clientTracingHandler) finishTrace(err error, ts trace.Span) {
84
83
// It creates a new outgoing carrier which serializes information about this
85
84
// span into gRPC Metadata, if TextMapPropagator is provided in the trace
86
85
// 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 ) {
91
87
// Add a "Delayed name resolution complete" event to the call span
92
88
// if there was name resolution delay. In case of multiple retry attempts,
93
89
// ensure that event is added only once.
@@ -102,7 +98,7 @@ func (h *clientTracingHandler) traceTagRPC(ctx context.Context, ai *attemptInfo,
102
98
carrier := otelinternaltracing .NewOutgoingCarrier (ctx )
103
99
h .options .TraceOptions .TextMapPropagator .Inject (ctx , carrier )
104
100
ai .traceSpan = span
105
- return carrier .Context ()
101
+ return carrier .Context (), ai
106
102
}
107
103
108
104
// createCallTraceSpan creates a call span to put in the provided context using
@@ -125,12 +121,7 @@ func (h *clientTracingHandler) HandleConn(context.Context, stats.ConnStats) {}
125
121
// TagRPC implements per RPC attempt context management for traces.
126
122
func (h * clientTracingHandler ) TagRPC (ctx context.Context , info * stats.RPCTagInfo ) context.Context {
127
123
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 )
134
125
return setRPCInfo (ctx , & rpcInfo {ai : ai })
135
126
}
136
127
@@ -141,15 +132,5 @@ func (h *clientTracingHandler) HandleRPC(ctx context.Context, rs stats.RPCStats)
141
132
logger .Error ("ctx passed into client side tracing handler trace event handling has no client attempt data present" )
142
133
return
143
134
}
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
- }
154
135
populateSpan (rs , ri .ai )
155
136
}
0 commit comments