Search in sources :

Example 6 with Reservoir

use of com.codahale.metrics.Reservoir in project riposte by Nike-Inc.

the class SignalFxEndpointMetricsHandlerTest method RollingWindowTimerBuilder_newMetric_creates_new_timer_with_SlidingTimeWindowArrayReservoir_with_expected_values.

@DataProvider(value = { "42     |   DAYS", "123    |   SECONDS", "999    |   MILLISECONDS", "3      |   HOURS" }, splitBy = "\\|")
@Test
public void RollingWindowTimerBuilder_newMetric_creates_new_timer_with_SlidingTimeWindowArrayReservoir_with_expected_values(long amount, TimeUnit timeUnit) {
    // given
    RollingWindowTimerBuilder rwtb = new RollingWindowTimerBuilder(amount, timeUnit);
    // when
    Timer timer = rwtb.newMetric();
    // then
    Histogram histogram = (Histogram) getInternalState(timer, "histogram");
    Reservoir reservoir = (Reservoir) getInternalState(histogram, "reservoir");
    assertThat(reservoir).isInstanceOf(SlidingTimeWindowArrayReservoir.class);
    // The expected value here comes from logic in the SlidingTimeWindowArrayReservoir constructor.
    assertThat(getInternalState(reservoir, "window")).isEqualTo(timeUnit.toNanos(amount) * 256);
}
Also used : Histogram(com.codahale.metrics.Histogram) Timer(com.codahale.metrics.Timer) Reservoir(com.codahale.metrics.Reservoir) SlidingTimeWindowArrayReservoir(com.codahale.metrics.SlidingTimeWindowArrayReservoir) RollingWindowTimerBuilder(com.nike.riposte.metrics.codahale.impl.SignalFxEndpointMetricsHandler.RollingWindowTimerBuilder) DataProvider(com.tngtech.java.junit.dataprovider.DataProvider) Test(org.junit.Test)

Example 7 with Reservoir

use of com.codahale.metrics.Reservoir in project torodb by torodb.

the class ToroMetricRegistry method timer.

/**
   *
   * @param name
   * @param resetOnSnapshot This is usually true if you're using snapshots as a means of defining
   *                        the window in which you want to calculate, say, the 99.9th percentile
   * @return
   */
public Timer timer(MetricName name, boolean resetOnSnapshot) {
    Reservoir reservoir;
    if (resetOnSnapshot) {
        reservoir = new HdrHistogramResetOnSnapshotReservoir();
    } else {
        reservoir = new HdrHistogramReservoir();
    }
    Timer timer = register(name, new Timer(reservoir));
    return timer;
}
Also used : HdrHistogramReservoir(org.mpierce.metrics.reservoir.hdrhistogram.HdrHistogramReservoir) Timer(com.codahale.metrics.Timer) HdrHistogramResetOnSnapshotReservoir(org.mpierce.metrics.reservoir.hdrhistogram.HdrHistogramResetOnSnapshotReservoir) HdrHistogramReservoir(org.mpierce.metrics.reservoir.hdrhistogram.HdrHistogramReservoir) HdrHistogramResetOnSnapshotReservoir(org.mpierce.metrics.reservoir.hdrhistogram.HdrHistogramResetOnSnapshotReservoir) Reservoir(com.codahale.metrics.Reservoir)

Example 8 with Reservoir

use of com.codahale.metrics.Reservoir in project spring-boot by spring-projects.

the class DropwizardMetricServices method register.

@SuppressWarnings("unchecked")
private <T extends Metric> T register(String name, MetricRegistrar<T> registrar) {
    Reservoir reservoir = this.reservoirFactory.getReservoir(name);
    if (reservoir == null) {
        return registrar.register(this.registry, name);
    }
    Metric metric = this.registry.getMetrics().get(name);
    if (metric != null) {
        registrar.checkExisting(metric);
        return (T) metric;
    }
    try {
        return this.registry.register(name, registrar.createForReservoir(reservoir));
    } catch (IllegalArgumentException ex) {
        Metric added = this.registry.getMetrics().get(name);
        registrar.checkExisting(metric);
        return (T) added;
    }
}
Also used : Reservoir(com.codahale.metrics.Reservoir) Metric(com.codahale.metrics.Metric)

Example 9 with Reservoir

use of com.codahale.metrics.Reservoir 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 10 with Reservoir

use of com.codahale.metrics.Reservoir in project lucene-solr by apache.

the class MetricsConfigTest method testDefaults.

@Test
public void testDefaults() throws Exception {
    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);
    Clock clk = ((MetricSuppliers.DefaultTimerSupplier) mgr.getTimerSupplier()).clk;
    assertTrue(clk instanceof Clock.UserTimeClock);
    Reservoir rsv = ((MetricSuppliers.DefaultTimerSupplier) mgr.getTimerSupplier()).getReservoir();
    assertTrue(rsv instanceof ExponentiallyDecayingReservoir);
}
Also used : ExponentiallyDecayingReservoir(com.codahale.metrics.ExponentiallyDecayingReservoir) Reservoir(com.codahale.metrics.Reservoir) ExponentiallyDecayingReservoir(com.codahale.metrics.ExponentiallyDecayingReservoir) UniformReservoir(com.codahale.metrics.UniformReservoir) SlidingTimeWindowReservoir(com.codahale.metrics.SlidingTimeWindowReservoir) Clock(com.codahale.metrics.Clock) NodeConfig(org.apache.solr.core.NodeConfig) Test(org.junit.Test)

Aggregations

Reservoir (com.codahale.metrics.Reservoir)13 Test (org.junit.Test)7 Histogram (com.codahale.metrics.Histogram)6 ExponentiallyDecayingReservoir (com.codahale.metrics.ExponentiallyDecayingReservoir)5 SlidingTimeWindowReservoir (com.codahale.metrics.SlidingTimeWindowReservoir)5 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)4 Timer (com.codahale.metrics.Timer)3 UniformReservoir (com.codahale.metrics.UniformReservoir)3 Clock (com.codahale.metrics.Clock)2 SlidingTimeWindowArrayReservoir (com.codahale.metrics.SlidingTimeWindowArrayReservoir)2 RollingWindowHistogramBuilder (com.nike.riposte.metrics.codahale.impl.SignalFxEndpointMetricsHandler.RollingWindowHistogramBuilder)2 RollingWindowTimerBuilder (com.nike.riposte.metrics.codahale.impl.SignalFxEndpointMetricsHandler.RollingWindowTimerBuilder)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 NodeConfig (org.apache.solr.core.NodeConfig)2 HdrHistogramReservoir (org.mpierce.metrics.reservoir.hdrhistogram.HdrHistogramReservoir)2 HdrHistogramResetOnSnapshotReservoir (org.mpierce.metrics.reservoir.hdrhistogram.HdrHistogramResetOnSnapshotReservoir)2 Metric (com.codahale.metrics.Metric)1 SlidingWindowReservoir (com.codahale.metrics.SlidingWindowReservoir)1 CachedHistogram (com.github.ambry.utils.CachedHistogram)1 PluginInfoInitialized (org.apache.solr.util.plugin.PluginInfoInitialized)1