Search in sources :

Example 6 with UniformReservoir

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);
}
Also used : SlidingTimeWindowReservoir(com.codahale.metrics.SlidingTimeWindowReservoir) UniformReservoir(com.codahale.metrics.UniformReservoir) Reservoir(com.codahale.metrics.Reservoir) ExponentiallyDecayingReservoir(com.codahale.metrics.ExponentiallyDecayingReservoir) UniformReservoir(com.codahale.metrics.UniformReservoir) SlidingTimeWindowReservoir(com.codahale.metrics.SlidingTimeWindowReservoir) NodeConfig(org.apache.solr.core.NodeConfig) Test(org.junit.Test)

Example 7 with UniformReservoir

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());
    }
}
Also used : Timer(com.codahale.metrics.Timer) UnknownHostException(java.net.UnknownHostException) UniformReservoir(com.codahale.metrics.UniformReservoir) InetAddress(java.net.InetAddress) ConfigValidationException(org.graylog2.plugin.validate.ConfigValidationException)

Example 8 with UniformReservoir

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");
}
Also used : Histogram(com.codahale.metrics.Histogram) MetricRegistry(com.codahale.metrics.MetricRegistry) UniformReservoir(com.codahale.metrics.UniformReservoir) Test(org.junit.jupiter.api.Test)

Example 9 with UniformReservoir

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);
}
Also used : Timer(com.codahale.metrics.Timer) UniformReservoir(com.codahale.metrics.UniformReservoir) Test(org.junit.Test)

Example 10 with UniformReservoir

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);
}
Also used : Histogram(com.codahale.metrics.Histogram) UniformReservoir(com.codahale.metrics.UniformReservoir) Test(org.junit.Test)

Aggregations

UniformReservoir (com.codahale.metrics.UniformReservoir)10 Test (org.junit.Test)6 Histogram (com.codahale.metrics.Histogram)5 Timer (com.codahale.metrics.Timer)3 ExponentiallyDecayingReservoir (com.codahale.metrics.ExponentiallyDecayingReservoir)2 Reservoir (com.codahale.metrics.Reservoir)2 SlidingTimeWindowReservoir (com.codahale.metrics.SlidingTimeWindowReservoir)2 Clock (com.codahale.metrics.Clock)1 MetricRegistry (com.codahale.metrics.MetricRegistry)1 SlidingWindowReservoir (com.codahale.metrics.SlidingWindowReservoir)1 Snapshot (com.codahale.metrics.Snapshot)1 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)1 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 RandomReadTest (org.apache.hadoop.hbase.PerformanceEvaluation.RandomReadTest)1 TestOptions (org.apache.hadoop.hbase.PerformanceEvaluation.TestOptions)1 NodeConfig (org.apache.solr.core.NodeConfig)1 PluginInfoInitialized (org.apache.solr.util.plugin.PluginInfoInitialized)1 ConfigValidationException (org.graylog2.plugin.validate.ConfigValidationException)1 Test (org.junit.jupiter.api.Test)1