Skip to content

stats/opentelemetry: record retry attempts from clientStream #8342

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

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3ba457e
Fixed retry attempts in HandleRPC
vinothkumarr227 May 19, 2025
5d19779
Fixed the review changes
vinothkumarr227 May 20, 2025
4245950
Fixed vet issues
vinothkumarr227 May 20, 2025
5347db1
Fixed the review changes
vinothkumarr227 May 21, 2025
99e88d8
Fixed the review changes
vinothkumarr227 May 22, 2025
586cf63
Fixed the review changes
vinothkumarr227 May 26, 2025
1bdad7e
Fixed the test cases
vinothkumarr227 May 26, 2025
39c5f0d
Fixed the review changes
vinothkumarr227 May 30, 2025
11523b6
small tweaks
vinothkumarr227 May 30, 2025
3720f4e
Fixed the review changes
vinothkumarr227 Jun 3, 2025
b97a2da
Fixed the test cases
vinothkumarr227 Jun 3, 2025
a0ef86c
Fixed the test cases pick issues
vinothkumarr227 Jun 3, 2025
ac79ad2
Fixed the event ignore issues
vinothkumarr227 Jun 4, 2025
10c6a90
Fixed the picker event issues
vinothkumarr227 Jun 4, 2025
1048040
Fixed the test cases
vinothkumarr227 Jun 4, 2025
05e2cc8
Fixed the review changes
vinothkumarr227 Jun 6, 2025
ba08688
small tweaks
vinothkumarr227 Jun 6, 2025
fe1831f
Fixed the review changes
vinothkumarr227 Jun 12, 2025
4f76f19
Fixed the review changes
vinothkumarr227 Jun 16, 2025
65da5d8
Merge remote-tracking branch 'origin/master' into stats-retry-attempt…
vinothkumarr227 Jun 20, 2025
d489c91
small tweaks
vinothkumarr227 Jun 20, 2025
8de4d5e
small tweaks
vinothkumarr227 Jun 25, 2025
1654ba1
Fixed the review changes
vinothkumarr227 Jul 2, 2025
06f350c
Fixed the server trace issues
vinothkumarr227 Jul 2, 2025
b944353
Fixed the review changes
vinothkumarr227 Jul 3, 2025
daef268
Fixed the review changes
vinothkumarr227 Jul 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions stats/opentelemetry/client_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ func getOrCreateCallInfo(ctx context.Context, cc *grpc.ClientConn, method string
target: cc.CanonicalTarget(),
method: determineMethod(method, opts...),
}
ci.previousRPCAttempts = new(atomic.Int32)
ci.previousRPCAttempts.Store(0)
ctx = setCallInfo(ctx, ci)
}
return ctx, ci
Expand Down
16 changes: 13 additions & 3 deletions stats/opentelemetry/client_tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@
// It creates a new outgoing carrier which serializes information about this
// span into gRPC Metadata, if TextMapPropagator is provided in the trace
// options. if TextMapPropagator is not provided, it returns the context as is.
func (h *clientTracingHandler) traceTagRPC(ctx context.Context, ai *attemptInfo, nameResolutionDelayed bool) (context.Context, *attemptInfo) {
//
// Note: The passed attemptInfo pointer (ai) is mutated in-place. Fields such as
// ai.traceSpan are updated directly. No new attemptInfo is returned.
func (h *clientTracingHandler) traceTagRPC(ctx context.Context, ai *attemptInfo, nameResolutionDelayed bool) context.Context {
// Add a "Delayed name resolution complete" event to the call span
// if there was name resolution delay. In case of multiple retry attempts,
// ensure that event is added only once.
Expand All @@ -98,7 +101,7 @@
carrier := otelinternaltracing.NewOutgoingCarrier(ctx)
h.options.TraceOptions.TextMapPropagator.Inject(ctx, carrier)
ai.traceSpan = span
return carrier.Context(), ai
return carrier.Context()
}

// createCallTraceSpan creates a call span to put in the provided context using
Expand All @@ -121,7 +124,14 @@
// TagRPC implements per RPC attempt context management for traces.
func (h *clientTracingHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context {
ctx, ai := getOrCreateRPCAttemptInfo(ctx)
ctx, ai = h.traceTagRPC(ctx, ai, info.NameResolutionDelay)
ci := getCallInfo(ctx)
if ci == nil {
logger.Error("context passed into client side stats handler (TagRPC) has no call info")
return ctx
}

Check warning on line 131 in stats/opentelemetry/client_tracing.go

View check run for this annotation

Codecov / codecov/patch

stats/opentelemetry/client_tracing.go#L129-L131

Added lines #L129 - L131 were not covered by tests
ai.previousRPCAttempts = uint32(ci.previousRPCAttempts.Load())
ai.ctx = ctx
ctx = h.traceTagRPC(ctx, ai, info.NameResolutionDelay)
return setRPCInfo(ctx, &rpcInfo{ai: ai})
}

Expand Down
Loading