question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't remove meters after a filter is added

See original GitHub issue

MeterRegistry.remove() fails to remove metrics that were created before a commonTags() filter was applied. It seems to apply the filter to the metric ID before trying to look it up, and so it finds nothing, and fails to delete it.

Tested using the latest version (io.micrometer:micrometer-core:1.2.1).

Here is my test case:

import io.micrometer.core.instrument.Metrics;
import io.micrometer.core.instrument.Timer;
import org.junit.Test;

import java.time.Duration;

import static org.junit.Assert.assertNull;

public class RemoveMetricTest {

    /**
     * This passes as expected
     */
    @Test
    public void testRemoveMetric() {
        Timer testTimer = Metrics.globalRegistry.timer("testTimer");
        testTimer.record(Duration.ofMillis(10));
        Metrics.globalRegistry.remove(testTimer);
        assertNull(Metrics.globalRegistry.find("testTimer").timer());
    }

    /**
     * This fails - the Timer does not get removed
     */
    @Test
    public void testRemoveMetricAfterAddingFilter() {
        Timer testTimer = Metrics.globalRegistry.timer("testTimer");
        testTimer.record(Duration.ofMillis(10));
        Metrics.globalRegistry.config().commonTags("foo", "bar");
        Metrics.globalRegistry.remove(testTimer);
        assertNull(Metrics.globalRegistry.find("testTimer").timer());
    }
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cyklcommented, Aug 13, 2020

I just faced a similar issue with a slightly different setup.

My application registers meters using the globalRegistry. Two MeterRegistry are added to the globalRegistry at startup, each registry has its own MeterFilter. When the application removes a meter, it is removed from the CompositeRegistry but not from the two terminal registries as a meter has different Meter.Id in each registry. I can open a dedicated issue if it helps.

0reactions
admoca60commented, Jan 28, 2021

I believe this is fixed along with #2354 - the test case in my original report now passes using version 1.6.3.

Exactly, as I wrote, the #2354 and #1597 are the same use case!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Clear or remove a filter - Microsoft Support
Remove all the filters in a worksheet​​ If you want to completely remove filters, go to the Data tab and click the Filter...
Read more >
How to Reset Your Indicator After Changing the Filter - YouTube
After putting a new filter in your BRITA Filter Jug, don't forget to reset the indicator so you'll ... Your browser can't play...
Read more >
Delete Hidden or Visible Records after Applying Filter in Excel
Download the featured file here: https://www.bluepecantraining.com/wp-content/uploads/2021/08/ Delete -Filtered-Records.
Read more >
Does your Filter Remove TDS from Water? If Not, Why?
This can cause the meters to show a higher TDS reading when in reality nothing has been added to the water. It proves...
Read more >
Refrigerator Will not dispense water after replacing filter. - iFixit
Water Tube in Door is Frozen. If the refrigerator water dispenser is not working the water supply tube in the door may be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found