Skip to content

Conversation

Sangamesh1997
Copy link
Contributor

@Sangamesh1997 Sangamesh1997 commented Sep 1, 2025

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.

@@ -466,6 +466,7 @@ private static final class ServerTracer extends ServerStreamTracer {
this.fullMethodName = fullMethodName;
this.streamPlugins = checkNotNull(streamPlugins, "streamPlugins");
this.stopwatch = module.stopwatchSupplier.get().start();
isGeneratedMethod = fullMethodName != null;
Copy link
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
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
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
Copy link
Member

@ejona86 ejona86 left a comment

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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