Skip to content
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

CompositeMeterRegistry filters are ignored if they are the child of another CompositeMeterRegistry #3020

Open
gatlee opened this issue Feb 11, 2022 · 7 comments
Labels
bug A general bug module: micrometer-api waiting for feedback We need additional information before we can continue
Milestone

Comments

@gatlee
Copy link

gatlee commented Feb 11, 2022

Describe the bug

  • CompositeMeterRegistry A contains CompositeMeterRegistry B contains some MeterRegistry C
  • If there is a filter on B and a meter is added to A, B's filter will be ignored and the meter will still be added to C

Environment

  • Micrometer version 1.7.3 & 1.82
  • Micrometer registry any
  • OS: macOS, Linux and Windows (CI)
  • Java version:
    openjdk version "1.8.0_292"
    OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_292-b10)
    OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.292-b10, mixed mode)

To Reproduce
How to reproduce the bug:

@Test 
void childCompositeMeterRegistryShouldApplyFilter {
        final CompositeMeterRegistry rootComposite = new CompositeMeterRegistry();
        final CompositeMeterRegistry childComposite = new CompositeMeterRegistry();
        final SimpleMeterRegistry simpleMeterRegistry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, mockClock);

        rootComposite.add(childComposite);

        childComposite.add(simpleMeterRegistry);
        childComposite.config().meterFilter(MeterFilter.denyNameStartsWith("deny"));

        rootComposite.counter("deny.item");

        assertThat(simpleMeterRegistry.getMeters(), empty());
}

Expected behavior
I would expect that the filters of the child CompositeMeterRegistry would be applied

@gatlee gatlee added the bug A general bug label Feb 11, 2022
@marcingrzejszczak
Copy link
Contributor

Is this still a problem using the latest Micrometer versions?

@marcingrzejszczak marcingrzejszczak added the waiting for feedback We need additional information before we can continue label Dec 20, 2023
Copy link

github-actions bot commented Jan 2, 2024

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Copy link

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2024
izeye added a commit to izeye/hello-micrometer that referenced this issue Jan 19, 2024
@izeye
Copy link
Contributor

izeye commented Jan 19, 2024

@marcingrzejszczak marcingrzejszczak added this to the 1.9.18 milestone Jan 19, 2024
marcingrzejszczak added a commit that referenced this issue Jan 19, 2024
without this change non composite descendant do not know about the configuration of their parents
with this change we're merging that configuration

fixes gh-3020
@lenin-jaganathan
Copy link
Contributor

I don't think adding meter filters of the child registry to the composite registry is a good thing. If there are multiple child registries added to a composite meter registry and each has a filter to allow only certain data for the registry, then adding all the meter filters to the composite will prevent from adding any meters.

E.g: Assume global has two registry implementations A and B. There is one-meter filter in each which does this,

  1. A has a meter filter that will say only allow meters with prefix "A".
  2. B has a meter filter that will say only allow meters with prefix "B".

If both of these are added to global, no meter will be registered since both cases cannot be true.

@marcingrzejszczak
Copy link
Contributor

I understand but why would you want to add both to global? If someone adds a meter filter on the composite then it seems to make sense to pass these filters to child registries?

@lenin-jaganathan
Copy link
Contributor

why would you want to add both to global?

Lof of open-source libraries (like reactor netty, resilience4j, etc.) add the metrics to global registries and users just wire up a registry implementation to export these metrics. So, you would need to add the registries to get these metrics. One more good use-case is to segregate the user code from registry-specific things. In case, ceratin data needs to be sent to a different back-end, we would just add a registry with the required filters.

If someone adds a meter filter on the composite then it seems to make sense to pass these filters to child registries?

This can be true but haven't given a lot of thought to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A general bug module: micrometer-api waiting for feedback We need additional information before we can continue
Projects
None yet
Development

No branches or pull requests

5 participants