Skip to content

OpenTelemetryMetricsModule : Ensure method name is recorded instead of "other" in OpenTelemetry metrics. - #12325

Closed
Sangamesh1997 wants to merge 1 commit into
grpc:masterfrom
Sangamesh1997:12117_issue_fixed
Closed

Sangamesh1997 wants to merge 1 commit into
grpc:masterfrom
Sangamesh1997:12117_issue_fixed

Conversation

@Sangamesh1997

@Sangamesh1997 Sangamesh1997 commented Sep 1, 2025 •

Copy link
Copy Markdown
Contributor

Fixes: #12117
current change sets isGenerated = true whenever fullMethodName != null in ServerTracer. This ensures OpenTelemetry metrics don’t fall back to "other" in early-cancel cases.

this.fullMethodName = fullMethodName;
this.streamPlugins = checkNotNull(streamPlugins, "streamPlugins");
this.stopwatch = module.stopwatchSupplier.get().start();
isGeneratedMethod = fullMethodName != null;

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.

This overrides early the reasoning specified in serverCallStarted but only till serverCallStarted is called. There will be higher cardinality metrics only in the small number of cases where the stream is closed before the server call is started.
@ejona86

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

An attacker has control of whether the stream is closed before the server call is started.

I'm not sure there's anything to do to fix that issue, except maybe by making some processing occur in a certain order in the case of cancellation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This != null check is also garbage. It is guaranteed to be non-null (see CallAttemptsTracerFactory's constructor), so this is the same as isGeneratedMethod = true

kannanjgithub
kannanjgithub previously approved these changes Sep 2, 2025

@ejona86 ejona86 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We need to either error in the side of too many "other"s or not error at all. We can't change this to erring by taking on extra memory usage.

@kannanjgithub
kannanjgithub dismissed their stale review September 3, 2025 09:51

As per conversation.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Dec 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

recordMethodName is incorrectly recording "other" when the stream is cancelled before the call is started

3 participants