use of org.apache.bookkeeper.stats.OpStatsData in project bookkeeper by apache.
the class CodahaleOpStatsTest method testToOpStatsData.
@Test
public void testToOpStatsData() {
OpStatsLogger logger = new CodahaleMetricsProvider().getStatsLogger("test").getOpStatsLogger("testLogger");
logger.registerSuccessfulValue(1);
// the following should not throw any exception
OpStatsData statsData = logger.toOpStatsData();
assertEquals(1, statsData.getNumSuccessfulEvents());
}
use of org.apache.bookkeeper.stats.OpStatsData in project bookkeeper by apache.
the class CodahaleOpStatsLogger method toOpStatsData.
/**
* This function should go away soon (hopefully).
*/
public synchronized OpStatsData toOpStatsData() {
long numFailed = fail.getCount();
long numSuccess = success.getCount();
Snapshot s = success.getSnapshot();
double avgLatencyMillis = s.getMean();
double[] defaultPercentiles = { 10, 50, 90, 99, 99.9, 99.99 };
long[] latenciesMillis = new long[defaultPercentiles.length];
Arrays.fill(latenciesMillis, Long.MAX_VALUE);
for (int i = 0; i < defaultPercentiles.length; i++) {
latenciesMillis[i] = (long) s.getValue(defaultPercentiles[i] / 100);
}
return new OpStatsData(numSuccess, numFailed, avgLatencyMillis, latenciesMillis);
}
Aggregations