Skip to content

Commit 95d4d21

Browse files
author
zh_yu
committed
Fix: unregister metrics
1 parent 650cbf7 commit 95d4d21

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

qmq-metrics-prometheus/src/main/java/qunar/tc/qmq/metrics/prometheus/PrometheusQmqMetricRegistry.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ public QmqTimer newTimer(final String name, final String[] tags, final String[]
9999

100100
@Override
101101
public void remove(final String name, final String[] tags, final String[] values) {
102-
// TODO(keli.wang): only remove child collectors for now, may we should remove whole metric in the future
103-
final SimpleCollector collector = cacheFor(new SimpleCollectorKey(name, tags));
104-
collector.remove(values);
102+
final Collector collector = CACHE.getIfPresent(new SimpleCollectorKey(name, tags));
103+
if (collector == null) return;
104+
CollectorRegistry.defaultRegistry.unregister(collector);
105105
}
106106

107107
private static abstract class Key<M extends Collector> {
@@ -145,7 +145,7 @@ private static class SimpleCollectorKey extends Key<SimpleCollector> {
145145

146146
@Override
147147
public SimpleCollector create() {
148-
throw new UnsupportedOperationException("cannot create simple collector");
148+
return null;
149149
}
150150
}
151151

0 commit comments

Comments
 (0)