Can't remove meters after a filter is added
See original GitHub issueMeterRegistry.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:
- Created 4 years ago
- Reactions:2
- Comments:12 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
Exactly, as I wrote, the #2354 and #1597 are the same use case!