PrometheusMetrics { public static Map<Integer, Map<SimpleCollector<?>, Set<List<String>>>> getRegisteredCollectors() { return Collections.unmodifiableMap(REGISTERED_COLLECTORS); } private  PrometheusMetrics(); static Counter.Child tmpFileOpenFailuresCounter(String eventName); static Counter.Child tmpFilesOpened(String eventName); static Counter.Child filesCommittedCounter(String eventName); static Counter.Child checkpointFailuresCounter(String eventName, int partition); static Counter.Child checkpointSuccessesCounter(String eventName, int partition); static Counter.Child messageWritingFailuresCounter(String eventName, int partition); static Counter.Child messageWrittenCounter(String eventName, int partition); static Counter.Child hearbeatsSentCounter(String eventName, int partition); static Gauge.Child currentRunningOffsetsGauge(String eventName, int partition); static Gauge.Child latestCommittedOffsetGauge(String eventName, int partition); static Gauge.Child latestCommittedTimestampGauge(String eventName, int partition); static void clearCollectors(); static void clearPartitionCollectors(int partition); static Map<Integer, Map<SimpleCollector<?>, Set<List<String>>>> getRegisteredCollectors();  }
@Test public void shouldRegisterCollectorOnlyOnce() { createCollectorsForEventPartition("event_1", 0); createCollectorsForEventPartition("event_1", 0); createCollectorsForEventPartition("event_2", 1); createCollectorsForEventPartition("event_2", 1); assertEquals(2, PrometheusMetrics.getRegisteredCollectors().size()); PrometheusMetrics.getRegisteredCollectors().get(0) .forEach((collectors, childLabels) -> assertEquals(1, childLabels.size())); PrometheusMetrics.getRegisteredCollectors().get(1) .forEach((collectors, childLabels) -> assertEquals(1, childLabels.size())); }