@Override
 public void processHistogram(MetricName name, Histogram histogram, PrintStream stream) {
   final Snapshot snapshot = histogram.getSnapshot();
   stream.printf(locale, "               min = %2.2f\n", histogram.getMin());
   stream.printf(locale, "               max = %2.2f\n", histogram.getMax());
   stream.printf(locale, "              mean = %2.2f\n", histogram.getMean());
   stream.printf(locale, "            stddev = %2.2f\n", histogram.getStdDev());
   stream.printf(locale, "            median = %2.2f\n", snapshot.getMedian());
   stream.printf(locale, "              75%% <= %2.2f\n", snapshot.get75thPercentile());
   stream.printf(locale, "              95%% <= %2.2f\n", snapshot.get95thPercentile());
   stream.printf(locale, "              98%% <= %2.2f\n", snapshot.get98thPercentile());
   stream.printf(locale, "              99%% <= %2.2f\n", snapshot.get99thPercentile());
   stream.printf(locale, "            99.9%% <= %2.2f\n", snapshot.get999thPercentile());
 }
Esempio n. 2
0
  @Test
  public void reportsHistogramValues() throws Exception {
    final Histogram histogram = mock(Histogram.class);
    when(histogram.getCount()).thenReturn(1L);
    when(histogram.getMax()).thenReturn(2L);
    when(histogram.getMean()).thenReturn(3.0);
    when(histogram.getMin()).thenReturn(4L);
    when(histogram.getStdDev()).thenReturn(5.0);

    final Snapshot snapshot = mock(Snapshot.class);
    when(snapshot.getMedian()).thenReturn(6.0);
    when(snapshot.get75thPercentile()).thenReturn(7.0);
    when(snapshot.get95thPercentile()).thenReturn(8.0);
    when(snapshot.get98thPercentile()).thenReturn(9.0);
    when(snapshot.get99thPercentile()).thenReturn(10.0);
    when(snapshot.get999thPercentile()).thenReturn(11.0);

    when(histogram.getSnapshot()).thenReturn(snapshot);

    reporter.report(
        this.<Gauge>map(),
        this.<Counter>map(),
        map("test.histogram", histogram),
        this.<Meter>map(),
        this.<Timer>map());

    verify(ganglia)
        .announce(
            "test.histogram.count", "1", GMetricType.DOUBLE, "", GMetricSlope.BOTH, 60, 0, "test");
    verify(ganglia)
        .announce(
            "test.histogram.max", "2", GMetricType.DOUBLE, "", GMetricSlope.BOTH, 60, 0, "test");
    verify(ganglia)
        .announce(
            "test.histogram.mean", "3.0", GMetricType.DOUBLE, "", GMetricSlope.BOTH, 60, 0, "test");
    verify(ganglia)
        .announce(
            "test.histogram.min", "4", GMetricType.DOUBLE, "", GMetricSlope.BOTH, 60, 0, "test");
    verify(ganglia)
        .announce(
            "test.histogram.stddev",
            "5.0",
            GMetricType.DOUBLE,
            "",
            GMetricSlope.BOTH,
            60,
            0,
            "test");
    verify(ganglia)
        .announce(
            "test.histogram.p50", "6.0", GMetricType.DOUBLE, "", GMetricSlope.BOTH, 60, 0, "test");
    verify(ganglia)
        .announce(
            "test.histogram.p75", "7.0", GMetricType.DOUBLE, "", GMetricSlope.BOTH, 60, 0, "test");
    verify(ganglia)
        .announce(
            "test.histogram.p95", "8.0", GMetricType.DOUBLE, "", GMetricSlope.BOTH, 60, 0, "test");
    verify(ganglia)
        .announce(
            "test.histogram.p98", "9.0", GMetricType.DOUBLE, "", GMetricSlope.BOTH, 60, 0, "test");
    verify(ganglia)
        .announce(
            "test.histogram.p99", "10.0", GMetricType.DOUBLE, "", GMetricSlope.BOTH, 60, 0, "test");
    verify(ganglia)
        .announce(
            "test.histogram.p999",
            "11.0",
            GMetricType.DOUBLE,
            "",
            GMetricSlope.BOTH,
            60,
            0,
            "test");
    verifyNoMoreInteractions(ganglia);
  }