-
Notifications
You must be signed in to change notification settings - Fork 4k
opentelemetry: Add target attribute filter for metrics #12587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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.
|
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. |
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.
|
/gcbrun |
…es for TargetFilter
ejona86
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I meant to improve when sending my last comment.
|
/gcbrun |
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