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

Bug: DropwizardMeterRegistry does not remove Gauges created by LongTaskTimer #2924

Closed
hendryluk opened this issue Dec 16, 2021 · 1 comment
Closed
Labels
bug A general bug registry: jmx A JMX Registry related issue
Milestone

Comments

@hendryluk
Copy link

hendryluk commented Dec 16, 2021

Steps to reproduce:

  1. Create a LongTaskTime onto a DropwizardMeterRegistry (e.g. JMX)
    MeterRegistry registry = newJmxMeterRegistry(JmxConfig.DEFAULT, Clock.SYSTEM);
    LongTaskTimer timer = registry.more().longTaskTimer("foo"); 
    timer.record(() => {});
    In JMX, this creates 3 gauge mbeans: foo.statistic.active, foo.statistic.max, and foo.statistic.duration.
  2. Remove the timer
    registry.remove(timer);
    timer.close();

Expected:

It should remove all those 3 gauges from the underlying registry (i.e. JMX in this case).

Actual:

All the 3 gauges associated with the LongTimerMetric remain in JMX

Cause:

DropwizardMeterRegistry#newLongTaskTimer creates 3 gauges (Active, Duration, and Max). However it never gets removed during DropwizardMeterRegistry#onMeterRemoved

Fix

In DropwizardMeterRegistry#onMeterRemoved, add the following:

if (meter instanceof LongTaskTimer) {
   for (Statistic statistic: Statistic.values()) {
      registry.remove(hierarchicalName(meter.getId().withTag(statistic)));
   }
}
@shakuzen shakuzen added registry: jmx A JMX Registry related issue bug A general bug labels Dec 16, 2021
@shakuzen shakuzen added this to the 1.7.x milestone Dec 16, 2021
@shakuzen
Copy link
Member

Thanks for the detailed report. It sounds like this should also be a problem for removing custom Meter implementations and Timer/DistributionSummary with histogram gauges configured.

Would you be interested and willing to submit a pull request for the fix to the 1.7.x branch?

@shakuzen shakuzen modified the milestones: 1.7.x, 1.8.x May 11, 2022
@jonatan-ivanov jonatan-ivanov modified the milestones: 1.8.x, 1.9.x Jan 12, 2023
@marcingrzejszczak marcingrzejszczak added waiting for feedback We need additional information before we can continue and removed waiting for feedback We need additional information before we can continue labels Dec 22, 2023
@jonatan-ivanov jonatan-ivanov modified the milestones: 1.9.x, 1.9.18 Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A general bug registry: jmx A JMX Registry related issue
Projects
None yet
Development

No branches or pull requests

4 participants