use of com.codahale.metrics.UniformReservoir in project lucene-solr by apache.
the class MetricsConfigTest method testCustomReservoir.
@Test
public void testCustomReservoir() throws Exception {
System.setProperty("timer.reservoir", UniformReservoir.class.getName());
System.setProperty("histogram.size", "2048");
System.setProperty("histogram.window", "600");
System.setProperty("histogram.reservoir", SlidingTimeWindowReservoir.class.getName());
NodeConfig cfg = loadNodeConfig();
SolrMetricManager mgr = new SolrMetricManager(loader, cfg.getMetricsConfig());
assertTrue(mgr.getCounterSupplier() instanceof MetricSuppliers.DefaultCounterSupplier);
assertTrue(mgr.getMeterSupplier() instanceof MetricSuppliers.DefaultMeterSupplier);
assertTrue(mgr.getTimerSupplier() instanceof MetricSuppliers.DefaultTimerSupplier);
assertTrue(mgr.getHistogramSupplier() instanceof MetricSuppliers.DefaultHistogramSupplier);
Reservoir rsv = ((MetricSuppliers.DefaultTimerSupplier) mgr.getTimerSupplier()).getReservoir();
assertTrue(rsv instanceof UniformReservoir);
rsv = ((MetricSuppliers.DefaultHistogramSupplier) mgr.getHistogramSupplier()).getReservoir();
assertTrue(rsv instanceof SlidingTimeWindowReservoir);
}
use of com.codahale.metrics.UniformReservoir in project graylog2-server by Graylog2.
the class GeoIpResolverConfigValidator method validateConfig.
private void validateConfig(GeoIpResolverConfig config) throws ConfigValidationException {
Timer timer = new Timer(new UniformReservoir());
try {
// A test address. This will NOT be in any database, but should only produce an
// AddressNotFoundException. Any other exception suggests an actual error such as
// a database file that does does not belong to the vendor selected
InetAddress testAddress = InetAddress.getByName("127.0.0.1");
validateGeoIpLocationResolver(config, timer, testAddress);
validateGeoIpAsnResolver(config, timer, testAddress);
} catch (UnknownHostException | IllegalArgumentException e) {
throw new ConfigValidationException(e.getMessage());
}
}
use of com.codahale.metrics.UniformReservoir in project dropwizard by dropwizard.
the class BootstrapTest method bringsYourOwnMetricRegistry.
@Test
void bringsYourOwnMetricRegistry() {
final MetricRegistry newRegistry = new MetricRegistry() {
@Override
public Histogram histogram(String name) {
Histogram existed = (Histogram) getMetrics().get(name);
return existed != null ? existed : new Histogram(new UniformReservoir());
}
};
bootstrap.setMetricRegistry(newRegistry);
bootstrap.registerMetrics();
assertThat(newRegistry.getNames()).contains("jvm.buffers.mapped.capacity", "jvm.threads.count", "jvm.memory.heap.usage", "jvm.attribute.vendor", "jvm.classloader.loaded", "jvm.filedescriptor");
}
use of com.codahale.metrics.UniformReservoir in project graylog2-server by Graylog2.
the class MetricUtilsTest method mapSupportsTimer.
@Test
public void mapSupportsTimer() {
final TestClock clock = new TestClock();
final Timer timer = new Timer(new UniformReservoir(), clock);
try (Timer.Context time = timer.time()) {
clock.setTick(5000L);
}
final Map<String, Object> map = MetricUtils.map("metric", timer);
assertThat(map).containsEntry("type", "timer").extracting("metric").extracting("rate").extracting("total").containsExactly(1.0D);
}
use of com.codahale.metrics.UniformReservoir in project graylog2-server by Graylog2.
the class MetricUtilsTest method mapSupportsHistogram.
@Test
public void mapSupportsHistogram() {
final Histogram histogram = new Histogram(new UniformReservoir());
histogram.update(23);
final Map<String, Object> map = MetricUtils.map("metric", histogram);
assertThat(map).containsEntry("type", "histogram").extracting("metric").extracting("count").containsExactly(1L);
}
Aggregations