-
Notifications
You must be signed in to change notification settings - Fork 462
Add ability to filter out metric by id name #5616
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: main
Are you sure you want to change the base?
Conversation
Users might want to the ability to filter out metrics that are not necessary for them to view. Created a static getMeterFilter function in MeterRegistryFactory to filter out metrics user does not want to see. Created new Property GENERAL_MICROMETER_ID_FILTERS, and filters specified via this property will be added to meter registries created in MeterInfoImpl Closes issue apache#4599
This PR is failing checks because we need to specifically allow the MeterFilter class within the apilyzer configuration. You need to insert the following: <allow>io[.]micrometer[.]core[.]instrument[.]config[.]MeterFilter</allow> to core/pom.xml, directly below where there is a similar statement for MeterRegistry, line 301, so that we then have the following: <allows>
<allow>io[.]micrometer[.]core[.]instrument[.]MeterRegistry</allow>
<allow>io[.]micrometer[.]core[.]instrument[.]config[.]MeterFilter</allow>
<allow>io[.]opentelemetry[.]api[.]OpenTelemetry</allow>
... |
…lyzer configuration.
…lyzer configuration.
core/src/main/java/org/apache/accumulo/core/spi/metrics/MeterRegistryFactory.java
Show resolved
Hide resolved
…csInfoImpl.java. Moved MeterRegistryFactoryTest.java test cases into the MetricsInfoImplTest.java file and changed variable types to reflect the new location of the code.
…csInfoImpl.java. Moved MeterRegistryFactoryTest.java test cases into the MetricsInfoImplTest.java file and changed variable types to reflect the new location of the code.
server/base/src/main/java/org/apache/accumulo/server/metrics/MetricsInfoImpl.java
Show resolved
Hide resolved
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.
This looks pretty good. I am wondering if we should switch the filtering from a "deny list" to an "accept list" i.e. instead of defining which meters we want to filter out, we define a filter for only the meters we want to see. I don't think it makes a huge difference but might make things more intuitive or safer but I'm open to considering others opinions on this.
server/base/src/main/java/org/apache/accumulo/server/metrics/MetricsInfoImpl.java
Outdated
Show resolved
Hide resolved
server/base/src/main/java/org/apache/accumulo/server/metrics/MetricsInfoImpl.java
Outdated
Show resolved
Hide resolved
*/ | ||
public static MeterFilter getMeterFilter(String patternList) { | ||
requireNonNull(patternList, "patternList must not be null"); | ||
Preconditions.checkArgument(!patternList.isEmpty(), "patternList must not be empty"); |
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.
I'm wondering if we should allow an empty value here. The default value is currently an empty String anyways. We could just handle an empty string as no filter.
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.
Wouldn't passing an empty string through the function defeat the purpose of getMeterFilter?
…erFilter function in MetricsInfoImpl, trimmed whitespace from patternList, set finalPredicate to id->false instead of null to OR the predicates together without having to set the first predicate equal to finalPredicate and so that the return statement doesn't have to include reuireNonNullElseGet
Users might want to the ability to filter out metrics that are not necessary for them to view. Created a static getMeterFilter function in MeterRegistryFactory to filter out metrics user does not want to see. Created new Property GENERAL_MICROMETER_ID_FILTERS, and filters specified via this property will be added to meter registries created in MeterInfoImpl
Closes issue #4599