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);
}
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;
}
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;
}
}
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);
}
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);
}
Aggregations