Skip to content

stats/opentelemetry: record retry attempts from clientStream#8342

Merged
eshitachandwani merged 56 commits intogrpc:masterfrom
vinothkumarr227:stats-retry-attempts-fix-8299
Sep 10, 2025
Merged

stats/opentelemetry: record retry attempts from clientStream#8342
eshitachandwani merged 56 commits intogrpc:masterfrom
vinothkumarr227:stats-retry-attempts-fix-8299

Conversation

@vinothkumarr227
Copy link
Contributor

@vinothkumarr227 vinothkumarr227 commented May 19, 2025

Fixes: #8299

RELEASE NOTES:

  • stats/opentelemetry: Retry attempts (grpc.previous-rpc-attempts) are now recorded as span attributes for non-transparent client retries.

@codecov
Copy link

codecov bot commented May 19, 2025

Codecov Report

❌ Patch coverage is 52.63158% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.50%. Comparing base (e60a04b) to head (c0e523c).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
stats/opentelemetry/client_tracing.go 52.63% 6 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8342      +/-   ##
==========================================
- Coverage   81.64%   81.50%   -0.15%     
==========================================
  Files         413      413              
  Lines       40621    40693      +72     
==========================================
- Hits        33167    33166       -1     
- Misses       5991     6000       +9     
- Partials     1463     1527      +64     
Files with missing lines Coverage Δ
stats/opentelemetry/opentelemetry.go 50.94% <ø> (-26.97%) ⬇️
stats/opentelemetry/trace.go 41.07% <ø> (-47.82%) ⬇️
stats/opentelemetry/client_tracing.go 55.31% <52.63%> (-32.19%) ⬇️

... and 24 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@purnesh42H purnesh42H added Type: Bug Area: Observability Includes Stats, Tracing, Channelz, Healthz, Binlog, Reflection, Admin, GCP Observability labels May 19, 2025
@purnesh42H purnesh42H added this to the 1.73 Release milestone May 19, 2025
Copy link
Contributor

@purnesh42H purnesh42H left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember we had separate tests for retries. This change should only affect that test. This change shouldn't affect tests which are doing only single attempt.

Copy link
Contributor

@purnesh42H purnesh42H left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vinothkumarr227 have you tested this to ensure its working correctly? I was under impression that TestTraceSpan_WithRetriesAndNameResolutionDelay will need changes for expected values. I think its not working as expected because you are not setting the count back to ctx after incrementing.

@dfawley dfawley assigned vinothkumarr227 and unassigned dfawley Aug 12, 2025
@vinothkumarr227 vinothkumarr227 removed their assignment Aug 13, 2025
Copy link
Member

@dfawley dfawley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delays in review here. LGTM after this one small change.

method: determineMethod(method, opts...),
target: cc.CanonicalTarget(),
method: determineMethod(method, opts...),
previousRPCAttempts: new(atomic.Uint32),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this a non-pointer type and then we don't need the new here or the chance to get nil panics.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@dfawley dfawley assigned vinothkumarr227 and unassigned dfawley Sep 5, 2025
@vinothkumarr227 vinothkumarr227 removed their assignment Sep 9, 2025
target: cc.CanonicalTarget(),
method: determineMethod(method, opts...),
previousRPCAttempts: new(atomic.Uint32),
previousRPCAttempts: atomic.Uint32{},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete this line. This is the zero value so it doesn't need explicit initialization.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@dfawley dfawley assigned vinothkumarr227 and unassigned dfawley Sep 9, 2025
@vinothkumarr227 vinothkumarr227 removed their assignment Sep 10, 2025
@eshitachandwani eshitachandwani merged commit c122250 into grpc:master Sep 10, 2025
15 checks passed
eshitachandwani added a commit to eshitachandwani/grpc-go that referenced this pull request Sep 10, 2025
eshitachandwani added a commit that referenced this pull request Sep 10, 2025
…8342)" (#8571)

This introduced flakiness in a test -
Test/TraceSpan_WithRetriesAndNameResolutionDelay
Failure:
https://github.com/grpc/grpc-go/actions/runs/17614152882/job/50042942932?pr=8547

Related issue: #8299

RELEASE NOTES: None
ulascansenturk added a commit to ulascansenturk/grpc-go that referenced this pull request Nov 20, 2025
…tionDelay

This commit fixes the flaky test TestTraceSpan_WithRetriesAndNameResolutionDelay
which was introduced in PR grpc#8342 and caused that PR to be reverted.

Root Cause:
The test had race conditions related to timing:
1. The goroutine that updates resolver state could complete before or after
   the delayed resolution event was fully processed and recorded in spans
2. Span export timing was not synchronized with test validation, causing
   the test to sometimes check spans before they were fully exported

Fix:
1. Added 'stateUpdated' event to synchronize between the resolver state
   update completing and span validation beginning
2. Added explicit wait for the stateUpdated event before validating spans
3. Added a 50ms sleep after RPC completion to give the span exporter time
   to process and export all spans before validation

Testing:
- Test now passes consistently (10+ consecutive runs)
- Passes with race detector enabled (-race flag)
- No data races detected

Fixes grpc#8700
ulascansenturk pushed a commit to ulascansenturk/grpc-go that referenced this pull request Nov 20, 2025
Fixes: grpc#8299

RELEASE NOTES:

- stats/opentelemetry: Retry attempts (`grpc.previous-rpc-attempts`) are
now recorded as span attributes for non-transparent client retries.
ulascansenturk added a commit to ulascansenturk/grpc-go that referenced this pull request Nov 20, 2025
…tionDelay

This commit fixes the flaky test TestTraceSpan_WithRetriesAndNameResolutionDelay
which was introduced in the previous commit and caused PR grpc#8342 to be reverted.

Root Cause:
The test had race conditions related to timing:
1. The goroutine that updates resolver state could complete before or after
   the delayed resolution event was fully processed and recorded in spans
2. Span export timing was not synchronized with test validation, causing
   the test to sometimes check spans before they were fully exported

Fix:
1. Added 'stateUpdated' event to synchronize between the resolver state
   update completing and span validation beginning
2. Added explicit wait for the stateUpdated event before validating spans
3. Added a 50ms sleep after RPC completion to give the span exporter time
   to process and export all spans before validation

Testing:
- Test now passes consistently (10+ consecutive runs)
- Passes with race detector enabled (-race flag)
- No data races detected

Fixes grpc#8700
ulascansenturk pushed a commit to ulascansenturk/grpc-go that referenced this pull request Jan 14, 2026
Fixes: grpc#8299

RELEASE NOTES:

- stats/opentelemetry: Retry attempts (`grpc.previous-rpc-attempts`) are
now recorded as span attributes for non-transparent client retries.
ulascansenturk added a commit to ulascansenturk/grpc-go that referenced this pull request Jan 14, 2026
…tionDelay

This commit fixes the flaky test TestTraceSpan_WithRetriesAndNameResolutionDelay
which was introduced in the previous commit and caused PR grpc#8342 to be reverted.

Root Cause:
The test had race conditions related to timing:
1. The goroutine that updates resolver state could complete before or after
   the delayed resolution event was fully processed and recorded in spans
2. Span export timing was not synchronized with test validation, causing
   the test to sometimes check spans before they were fully exported

Fix:
1. Added 'stateUpdated' event to synchronize between the resolver state
   update completing and span validation beginning
2. Added explicit wait for the stateUpdated event before validating spans
3. Added a 50ms sleep after RPC completion to give the span exporter time
   to process and export all spans before validation

Testing:
- Test now passes consistently (10+ consecutive runs)
- Passes with race detector enabled (-race flag)
- No data races detected

Fixes grpc#8700
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Observability Includes Stats, Tracing, Channelz, Healthz, Binlog, Reflection, Admin, GCP Observability Type: Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Retry Attempts are not available in client-stats

6 participants