Skip to content

Commit

Permalink
For long task timers removes entries from Dropwizard registry
Browse files Browse the repository at this point in the history
fixes gh-2924
  • Loading branch information
marcingrzejszczak committed Dec 22, 2023
1 parent e988e3a commit 08573c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public DropwizardMeterRegistry(DropwizardConfig config, MetricRegistry registry,

private void onMeterRemoved(Meter meter) {
registry.remove(hierarchicalName(meter.getId()));
if (meter instanceof LongTaskTimer) {
for (Statistic statistic : Statistic.values()) {
registry.remove(hierarchicalName(meter.getId().withTag(statistic)));
}
}
}

public MetricRegistry getDropwizardRegistry() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,13 @@ void removeShouldWork() {
assertThat(registry.getDropwizardRegistry().getMeters()).isEmpty();
}

@Issue("#2924")
@Test
void removeShouldWorkForLongTaskTimer() {
LongTaskTimer timer = LongTaskTimer.builder("foo").register(registry);
assertThat(registry.getDropwizardRegistry().getGauges()).hasSize(3);
registry.remove(timer);
assertThat(registry.getDropwizardRegistry().getGauges()).isEmpty();
}

}

0 comments on commit 08573c6

Please sign in to comment.