### Question:
PrometheusMetricsProvider implements StatsProvider { @Override public StatsLogger getStatsLogger(String scope) { return this.cachingStatsProvider.getStatsLogger(scope); } PrometheusMetricsProvider();  PrometheusMetricsProvider(CollectorRegistry registry); @Override void start(Configuration conf); @Override void stop(); @Override StatsLogger getStatsLogger(String scope); @Override void writeAllMetrics(Writer writer); @Override String getStatsName(String... statsComponents); static final String PROMETHEUS_STATS_HTTP_ENABLE; static final boolean DEFAULT_PROMETHEUS_STATS_HTTP_ENABLE; static final String PROMETHEUS_STATS_HTTP_PORT; static final int DEFAULT_PROMETHEUS_STATS_HTTP_PORT; static final String PROMETHEUS_STATS_LATENCY_ROLLOVER_SECONDS; static final int DEFAULT_PROMETHEUS_STATS_LATENCY_ROLLOVER_SECONDS; }### Answer:
@Test public void testCache() { PrometheusMetricsProvider provider = new PrometheusMetricsProvider(); StatsLogger statsLogger = provider.getStatsLogger("test"); OpStatsLogger opStatsLogger1 = statsLogger.getOpStatsLogger("optest"); OpStatsLogger opStatsLogger2 = statsLogger.getOpStatsLogger("optest"); assertSame(opStatsLogger1, opStatsLogger2); Counter counter1 = statsLogger.getCounter("countertest"); Counter counter2 = statsLogger.getCounter("countertest"); assertSame(counter1, counter2); StatsLogger scope1 = statsLogger.scope("scopetest"); StatsLogger scope2 = statsLogger.scope("scopetest"); assertSame(scope1, scope2); }
@Test public void testTwoCounters() throws Exception { PrometheusMetricsProvider provider = new PrometheusMetricsProvider(); StatsLogger statsLogger = provider.getStatsLogger("test"); Counter counter1 = statsLogger.getCounter("counter"); Counter counter2 = statsLogger.getCounter("counter"); assertEquals(counter1, counter2); assertSame(counter1, counter2); assertEquals(1, provider.counters.size()); }