Skip to content

fix: fix exporting grpc metrics#13376

Merged
mutianf merged 2 commits into
googleapis:mainfrom
mutianf:grpc_metrics
Jun 5, 2026
Merged

fix: fix exporting grpc metrics#13376
mutianf merged 2 commits into
googleapis:mainfrom
mutianf:grpc_metrics

Conversation

@mutianf
Copy link
Copy Markdown
Contributor

@mutianf mutianf commented Jun 5, 2026

No description provided.

@mutianf mutianf requested review from a team as code owners June 5, 2026 16:53
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a CUSTOM_METRIC_PREFIX constant in MetricsImpl and updates the metric filtering logic. Specifically, the built-in OpenTelemetry exporter filter is modified to only allow metrics registered in metricRegistry that do not start with the custom metric prefix. Additionally, CustomAttemptLatency is updated to use the new prefix constant. Feedback on these changes highlights that the new filtering logic will inadvertently filter out gRPC metrics (which start with grpc.) because they are not registered in metricRegistry, and suggests updating the filter to explicitly allow them.

Comment on lines +323 to +327
input -> {
String name = input.getName();
return metricRegistry.getMetric(name) != null
&& !name.startsWith(CUSTOM_METRIC_PREFIX);
}),
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.

high

The current filter only allows metrics that are registered in metricRegistry. Since gRPC metrics (which typically start with grpc.) are registered directly by the gRPC library and are not present in metricRegistry, they will be filtered out and not exported. To fix this, explicitly allow metrics starting with grpc. in the filter.

Suggested change
input -> {
String name = input.getName();
return metricRegistry.getMetric(name) != null
&& !name.startsWith(CUSTOM_METRIC_PREFIX);
}),
input -> {
String name = input.getName();
return (metricRegistry.getMetric(name) != null || name.startsWith("grpc."))
&& !name.startsWith(CUSTOM_METRIC_PREFIX);
}),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@mutianf mutianf merged commit 4159d2d into googleapis:main Jun 5, 2026
182 of 183 checks passed
@mutianf mutianf deleted the grpc_metrics branch June 5, 2026 20:07
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.

2 participants