opentelemetry: Add target attribute filter for metrics#12587
Merged
kannanjgithub merged 11 commits intogrpc:masterfrom Jan 9, 2026
Merged
opentelemetry: Add target attribute filter for metrics#12587kannanjgithub merged 11 commits intogrpc:masterfrom
kannanjgithub merged 11 commits intogrpc:masterfrom
Conversation
Introduce an optional Predicate<String> targetAttributeFilter in the OpenTelemetryMetricsModule to control how grpc.target is recorded in metrics. Also add support in GrpcOpenTelemetry.Builder to allow users to configure this filter when building the module.
Contributor
Author
|
Thanks for looping me in. I'll keep an eye on the Android desugaring discussion. In the meantime, I've updated the PR and gRFC A109 with a null-safety check for the filtering logic to make it more robust. If it turns out that using Java 8's Predicate causes compatibility concerns, I'm happy to adjust the interface accordingly (e.g., using a small custom functional interface), based on what the maintainers think is best. |
ejona86
reviewed
Jan 2, 2026
opentelemetry/src/main/java/io/grpc/opentelemetry/GrpcOpenTelemetry.java
Show resolved
Hide resolved
opentelemetry/src/main/java/io/grpc/opentelemetry/GrpcOpenTelemetry.java
Outdated
Show resolved
Hide resolved
Replace Predicate with a package-private TargetFilter interface in fields to ensure compatibility with Android API levels < 24. This prevents potential runtime issues for Android users who do not use the filtering feature. Mark the API as experimental and link the tracking issue.
Member
|
/gcbrun |
…es for TargetFilter
ejona86
approved these changes
Jan 6, 2026
Member
|
/gcbrun |
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.
Introduce an optional Predicate targetAttributeFilter to control how grpc.target is recorded in OpenTelemetry client metrics.
When a filter is provided, targets rejected by the predicate are normalized to "other" to reduce grpc.target metric cardinality, while accepted targets are recorded as-is. If no filter is set, existing behavior is preserved.
This change adds a new Builder API on GrpcOpenTelemetry to allow applications to configure the filter. Tests verify both the Builder wiring and the target normalization behavior.
This is an optional API; annotation (e.g., experimental) can be added per maintainer guidance.
Refs #12322
Related: gRFC A109 – Target Attribute Filter for OpenTelemetry Metrics
grpc/proposal#528