@Test public void metricsAreProducedAndFiltered() { CassandraClientPoolMetrics metrics = new CassandraClientPoolMetrics(metricsManager); AtomicLong poolOne = new AtomicLong(3); AtomicLong poolTwo = new AtomicLong(4); AtomicLong poolThree = new AtomicLong(20); metrics.registerPoolMetric(CassandraClientPoolHostLevelMetric.MEAN_ACTIVE_TIME_MILLIS, poolOne::get, 1); metrics.registerPoolMetric(CassandraClientPoolHostLevelMetric.MEAN_ACTIVE_TIME_MILLIS, poolTwo::get, 2); metrics.registerPoolMetric(CassandraClientPoolHostLevelMetric.MEAN_ACTIVE_TIME_MILLIS, poolThree::get, 3); assertThat(metricsManager.getTaggedRegistry().getMetrics()) .containsKey(createMeanActiveTimeMillisMetric("pool1")) .containsKey(createMeanActiveTimeMillisMetric("pool2")) .containsKey(createMeanActiveTimeMillisMetric("pool3")) .containsKey(createMeanActiveTimeMillisMetric("mean")); assertThat(metricsManager.getPublishableMetrics().getMetrics()) .doesNotContainKey(createMeanActiveTimeMillisMetric("pool1")) .doesNotContainKey(createMeanActiveTimeMillisMetric("pool2")) .containsKey(createMeanActiveTimeMillisMetric("pool3")) .containsKey(createMeanActiveTimeMillisMetric("mean")); }
@SuppressWarnings("unchecked") public void registerPoolMetric( CassandraClientPoolHostLevelMetric metric, Gauge<Long> gauge, int poolNumber) { MetricPublicationFilter filter = outlierControllers.get(metric).registerAndCreateFilter(gauge); registerPoolMetricsToRegistry(metric, gauge, poolNumber, filter); }
CassandraClientPoolMetrics { @SuppressWarnings("unchecked") public void registerPoolMetric( CassandraClientPoolHostLevelMetric metric, Gauge<Long> gauge, int poolNumber) { MetricPublicationFilter filter = outlierControllers.get(metric).registerAndCreateFilter(gauge); registerPoolMetricsToRegistry(metric, gauge, poolNumber, filter); } }
CassandraClientPoolMetrics { @SuppressWarnings("unchecked") public void registerPoolMetric( CassandraClientPoolHostLevelMetric metric, Gauge<Long> gauge, int poolNumber) { MetricPublicationFilter filter = outlierControllers.get(metric).registerAndCreateFilter(gauge); registerPoolMetricsToRegistry(metric, gauge, poolNumber, filter); } CassandraClientPoolMetrics(MetricsManager metricsManager); }
CassandraClientPoolMetrics { @SuppressWarnings("unchecked") public void registerPoolMetric( CassandraClientPoolHostLevelMetric metric, Gauge<Long> gauge, int poolNumber) { MetricPublicationFilter filter = outlierControllers.get(metric).registerAndCreateFilter(gauge); registerPoolMetricsToRegistry(metric, gauge, poolNumber, filter); } CassandraClientPoolMetrics(MetricsManager metricsManager); void registerAggregateMetrics(Supplier<Integer> blacklistSize); void recordRequestOnHost(CassandraClientPoolingContainer hostPool); void recordExceptionOnHost(CassandraClientPoolingContainer hostPool); void recordConnectionExceptionOnHost(CassandraClientPoolingContainer hostPool); void recordPoolExhaustion(); @SuppressWarnings("unchecked") // Guaranteed to have the correct type void registerPoolMetric(
            CassandraClientPoolHostLevelMetric metric,
            Gauge<Long> gauge,
            int poolNumber); }
CassandraClientPoolMetrics { @SuppressWarnings("unchecked") public void registerPoolMetric( CassandraClientPoolHostLevelMetric metric, Gauge<Long> gauge, int poolNumber) { MetricPublicationFilter filter = outlierControllers.get(metric).registerAndCreateFilter(gauge); registerPoolMetricsToRegistry(metric, gauge, poolNumber, filter); } CassandraClientPoolMetrics(MetricsManager metricsManager); void registerAggregateMetrics(Supplier<Integer> blacklistSize); void recordRequestOnHost(CassandraClientPoolingContainer hostPool); void recordExceptionOnHost(CassandraClientPoolingContainer hostPool); void recordConnectionExceptionOnHost(CassandraClientPoolingContainer hostPool); void recordPoolExhaustion(); @SuppressWarnings("unchecked") // Guaranteed to have the correct type void registerPoolMetric(
            CassandraClientPoolHostLevelMetric metric,
            Gauge<Long> gauge,
            int poolNumber);  }