use of org.apache.calcite.avatica.metrics.Histogram in project calcite-avatica by apache.
the class DropwizardMetricsSystemTest method testHistogram.
@Test
public void testHistogram() {
final String name = "histogram";
final com.codahale.metrics.Histogram mockHistogram = mock(com.codahale.metrics.Histogram.class);
when(mockRegistry.histogram(name)).thenReturn(mockHistogram);
Histogram histogram = metrics.getHistogram(name);
long[] long_values = new long[] { 1L, 5L, 15L, 30L, 60L };
for (long value : long_values) {
histogram.update(value);
}
for (long value : long_values) {
verify(mockHistogram).update(value);
}
int[] int_values = new int[] { 2, 6, 16, 31, 61 };
for (int value : int_values) {
histogram.update(value);
}
for (int value : int_values) {
verify(mockHistogram).update(value);
}
}
use of org.apache.calcite.avatica.metrics.Histogram in project calcite-avatica by apache.
the class NoopMetricsSystemTest method testNoNulls.
@Test
public void testNoNulls() {
// The NOOP implementation should act as a real implementation, no "nulls" allowed.
MetricsSystem metrics = NoopMetricsSystem.getInstance();
Counter counter = metrics.getCounter("counter");
counter.decrement();
counter.increment();
counter.decrement(1L);
counter.increment(1L);
Histogram histogram = metrics.getHistogram("histogram");
histogram.update(1);
histogram.update(1L);
Timer timer = metrics.getTimer("timer");
Context context = timer.start();
context.close();
Context contextTwo = timer.start();
assertTrue("Timer's context should be a singleton", context == contextTwo);
Meter meter = metrics.getMeter("meter");
meter.mark();
meter.mark(5L);
metrics.register("gauge", new Gauge<Long>() {
@Override
public Long getValue() {
return 42L;
}
});
}
Aggregations