Skip to content

stats/opentelemetry: set ai.method in clientTracingHandler.TagRPC#9116

Open
c-tonneslan wants to merge 2 commits into
grpc:masterfrom
c-tonneslan:fix/tracing-method-name
Open

stats/opentelemetry: set ai.method in clientTracingHandler.TagRPC#9116
c-tonneslan wants to merge 2 commits into
grpc:masterfrom
c-tonneslan:fix/tracing-method-name

Conversation

@c-tonneslan
Copy link
Copy Markdown

@c-tonneslan c-tonneslan commented May 11, 2026

Fixes #9097

When only the tracing handler is registered (without the metrics handler), ai.method is never set 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 handles this correctly:

ai.method = removeLeadingSlash(info.FullMethodName)

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.method before the tracing handler sees it — that's why the bug was hidden. Using tracing without metrics produces broken span names.

RELEASE NOTES:

  • stats/opentelemetry: Fix client tracing attempt span names when using tracing without metrics

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
@easwars easwars requested a review from mbissa May 11, 2026 20:33
@easwars easwars added Type: Bug Area: Observability Includes Stats, Tracing, Channelz, Healthz, Binlog, Reflection, Admin, GCP Observability labels May 11, 2026
@easwars easwars added this to the 1.82 Release milestone May 11, 2026
@easwars
Copy link
Copy Markdown
Contributor

easwars commented May 11, 2026

@mbissa : Could you please make a first pass on this as you are familiar with the issue. Thanks.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.06%. Comparing base (1c63fa5) to head (55a71d4).
⚠️ Report is 1 commits behind head on master.

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     
Files with missing lines Coverage Δ
stats/opentelemetry/client_tracing.go 86.56% <100.00%> (+0.20%) ⬆️

... and 25 files with indirect coverage changes

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

logger.Error("context passed into client side stats handler (TagRPC) has no call info")
return ctx
}
ri.ai.method = removeLeadingSlash(info.FullMethodName)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add a test that verifies that it works without metrics handler?

@mbissa
Copy link
Copy Markdown
Contributor

mbissa commented May 13, 2026

@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.
@linux-foundation-easycla
Copy link
Copy Markdown

CLA Not Signed

@easwars
Copy link
Copy Markdown
Contributor

easwars commented May 13, 2026

@c-tonneslan

Please sign the CLA so that we can start reviewing your PR.

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 Status: Requires Reporter Clarification Type: Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Method name is not populated in tracing during TagRPC

3 participants