@Override public void gauge(String label, double value, String topic) { Stats.setGauge(label, value); } }
@Override public void increment(String label, int delta, String topic) { Stats.incr(label, delta); }
@Override public void metric(String label, double value, String topic) { Stats.addMetric(label, (int) value); }
@Override public OpStatsData toOpStatsData() { long numSuccess = successCounter.apply(); long numFailures = failureCounter.apply(); com.twitter.ostrich.stats.Distribution distribution = successMetric.apply(); com.twitter.ostrich.stats.Histogram histogram = distribution.histogram(); double avgLatency = distribution.average(); long[] percentiles = new long[PERCENTILES.length]; int i = 0; for (double percentile : PERCENTILES) { percentiles[i] = histogram.getPercentile(percentile); ++i; } return new OpStatsData(numSuccess, numFailures, avgLatency, percentiles); }
@Override public void inc() { this.ostrichCounter.incr(); }
public static void clearLabel(String name) { long threadId = Thread.currentThread().getId(); name += "." + threadId; Stats.clearLabel(name); }
public static void setLabel(String name, String value) { long threadId = Thread.currentThread().getId(); name += "." + threadId; Stats.setLabel(name, value); }
@Override public Long get() { return this.ostrichCounter.apply(); } }
@Override public void clear() { this.ostrichCounter.reset(); }
@Override public void increment(String label, String topic) { Stats.incr(label); }
@Test public void metric() throws Exception { metricCollector.metric("expectedLabel", 42.0, "ignored"); PowerMockito.verifyStatic(); Stats.addMetric("expectedLabel", 42); }
@Test public void gauge() throws Exception { metricCollector.gauge("expectedLabel", 4.2, "ignored"); PowerMockito.verifyStatic(); Stats.setGauge("expectedLabel", 4.2); } }
@Override public void dec() { this.ostrichCounter.incr(-1); }
public static void incr(String name) { Stats.incr(name); }
public static void addMetric(String name, int value) { Stats.addMetric(name, value); }
@Test public void incrementByOne() throws Exception { metricCollector.increment("expectedLabel", "ignored"); PowerMockito.verifyStatic(); Stats.incr("expectedLabel"); }
@Test public void increment() throws Exception { metricCollector.increment("expectedLabel", 42, "ignored"); PowerMockito.verifyStatic(); Stats.incr("expectedLabel", 42); }