stats/opentelemetry: set ai.method in clientTracingHandler.TagRPC#9116
Open
c-tonneslan wants to merge 2 commits into
Open
stats/opentelemetry: set ai.method in clientTracingHandler.TagRPC#9116c-tonneslan wants to merge 2 commits into
c-tonneslan wants to merge 2 commits into
Conversation
When only the tracing handler is registered (without the metrics handler), ai.method is never populated before traceTagRPC is called, so the attempt span gets named "Attempt." instead of something like "Attempt.grpc.testing.TestService.UnaryCall". The metrics handler's TagRPC already does this correctly: ai.method = removeLeadingSlash(info.FullMethodName) Add the same assignment to the tracing handler. When both handlers are registered, the metrics handler typically runs first and sets ai.method before the tracing handler sees it, which is why existing e2e tests pass. But using tracing alone produces broken span names. Fixes grpc#9097
Contributor
|
@mbissa : Could you please make a first pass on this as you are familiar with the issue. Thanks. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9116 +/- ##
==========================================
- Coverage 83.30% 83.06% -0.25%
==========================================
Files 413 413
Lines 33482 33483 +1
==========================================
- Hits 27892 27812 -80
- Misses 4190 4246 +56
- Partials 1400 1425 +25
🚀 New features to boost your workflow:
|
mbissa
reviewed
May 13, 2026
| logger.Error("context passed into client side stats handler (TagRPC) has no call info") | ||
| return ctx | ||
| } | ||
| ri.ai.method = removeLeadingSlash(info.FullMethodName) |
Contributor
There was a problem hiding this comment.
Can you add a test that verifies that it works without metrics handler?
Contributor
|
@c-tonneslan assigning it back to you to add a test. You can look at the issue description #9097 where this is discussed, it is part of a test. |
… config Adds TestSpan_TraceOnlyNoMetricsHandler to verify that the client attempt span gets the correct method name when OpenTelemetry is configured with tracing but no metrics handler. The span name "Attempt.grpc.testing.TestService.UnaryCall" would come out as "Attempt." before the TagRPC fix because ri.ai.method was never populated in that code path.
|
Contributor
|
Please sign the CLA so that we can start reviewing your PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9097
When only the tracing handler is registered (without the metrics handler),
ai.methodis never set beforetraceTagRPCis called, so the attempt span gets named"Attempt."instead of something like"Attempt.grpc.testing.TestService.UnaryCall".The metrics handler's
TagRPCalready handles this correctly:This PR adds the same assignment to
clientTracingHandler.TagRPC. One line.The existing e2e tests all register both metrics and tracing together, so when metrics runs first it sets
ai.methodbefore the tracing handler sees it — that's why the bug was hidden. Using tracing without metrics produces broken span names.RELEASE NOTES: