@Test public void testUnregister() { Collector g = Gauge.build().name("g").help("h").register(registry); Collector c = Counter.build().name("c").help("h").register(registry); List<Collector.MetricFamilySamples> mfs = Collections.list(registry.metricFamilySamples()); assertEquals(2, mfs.size()); registry.unregister(g); mfs = Collections.list(registry.metricFamilySamples()); assertEquals(1, mfs.size()); assertEquals("c", mfs.get(0).name); }
public void unregister(Collector m) { synchronized (namesCollectorsLock) { List<String> names = collectorsToNames.remove(m); for (String name : names) { namesToCollectors.remove(name); } } }
CollectorRegistry { public void unregister(Collector m) { synchronized (namesCollectorsLock) { List<String> names = collectorsToNames.remove(m); for (String name : names) { namesToCollectors.remove(name); } } } }
CollectorRegistry { public void unregister(Collector m) { synchronized (namesCollectorsLock) { List<String> names = collectorsToNames.remove(m); for (String name : names) { namesToCollectors.remove(name); } } } CollectorRegistry();  CollectorRegistry(boolean autoDescribe); }
CollectorRegistry { public void unregister(Collector m) { synchronized (namesCollectorsLock) { List<String> names = collectorsToNames.remove(m); for (String name : names) { namesToCollectors.remove(name); } } } CollectorRegistry();  CollectorRegistry(boolean autoDescribe); void register(Collector m); void unregister(Collector m); void clear(); Enumeration<Collector.MetricFamilySamples> metricFamilySamples(); Enumeration<Collector.MetricFamilySamples> filteredMetricFamilySamples(Set<String> includedNames); Double getSampleValue(String name); Double getSampleValue(String name, String[] labelNames, String[] labelValues); }
CollectorRegistry { public void unregister(Collector m) { synchronized (namesCollectorsLock) { List<String> names = collectorsToNames.remove(m); for (String name : names) { namesToCollectors.remove(name); } } } CollectorRegistry();  CollectorRegistry(boolean autoDescribe); void register(Collector m); void unregister(Collector m); void clear(); Enumeration<Collector.MetricFamilySamples> metricFamilySamples(); Enumeration<Collector.MetricFamilySamples> filteredMetricFamilySamples(Set<String> includedNames); Double getSampleValue(String name); Double getSampleValue(String name, String[] labelNames, String[] labelValues); static final CollectorRegistry defaultRegistry; }