@Test public void reportsTimerValues() throws Exception { final Timer timer = mock(Timer.class); when(timer.eventType()).thenReturn("events"); when(timer.durationUnit()).thenReturn(TimeUnit.MILLISECONDS); when(timer.rateUnit()).thenReturn(TimeUnit.SECONDS); when(timer.count()).thenReturn(1L); when(timer.meanRate()).thenReturn(2.0); when(timer.oneMinuteRate()).thenReturn(3.0); when(timer.fiveMinuteRate()).thenReturn(4.0); when(timer.fifteenMinuteRate()).thenReturn(5.0); when(timer.max()).thenReturn(2.0); when(timer.mean()).thenReturn(3.0); when(timer.min()).thenReturn(4.0); when(timer.stdDev()).thenReturn(5.0); final Snapshot snapshot = mock(Snapshot.class); when(snapshot.getMedian()).thenReturn((double) 500); when(snapshot.get75thPercentile()).thenReturn((double) 600); when(snapshot.get95thPercentile()).thenReturn((double) 700); when(snapshot.get98thPercentile()).thenReturn((double) 800); when(snapshot.get99thPercentile()).thenReturn((double) 900); when(snapshot.get999thPercentile()).thenReturn((double) 1000); when(timer.getSnapshot()).thenReturn(snapshot); reporter.processTimer(name("another.timer"), timer, null); verify(output).send(decode("name = t.test.another.timer.max, value = 2.0, group = timer, units = MILLISECONDS")); verify(output).send(decode("name = t.test.another.timer.mean, value = 3.0, group = timer, units = MILLISECONDS")); verify(output).send(decode("name = t.test.another.timer.min, value = 4.0, group = timer, units = MILLISECONDS")); verify(output).send(decode("name = t.test.another.timer.stddev, value = 5.0, group = timer, units = MILLISECONDS")); verify(output).send(decode("name = t.test.another.timer.median, value = 500.0, group = timer, units = MILLISECONDS")); verify(output).send(decode("name = t.test.another.timer.75percentile, value = 600.0, group = timer, units = MILLISECONDS")); verify(output).send(decode("name = t.test.another.timer.95percentile, value = 700.0, group = timer, units = MILLISECONDS")); verify(output).send(decode("name = t.test.another.timer.98percentile, value = 800.0, group = timer, units = MILLISECONDS")); verify(output).send(decode("name = t.test.another.timer.99percentile, value = 900.0, group = timer, units = MILLISECONDS")); verify(output).send(decode("name = t.test.another.timer.999percentile, value = 1000.0, group = timer, units = MILLISECONDS")); verify(output).send(decode("name = t.test.another.timer.count, value = 1, group = metered, units = events")); verify(output).send(decode("name = t.test.another.timer.meanRate, value = 2.0, group = metered, units = events/second")); verify(output).send(decode("name = t.test.another.timer.1MinuteRate, value = 3.0, group = metered, units = events/second")); verify(output).send(decode("name = t.test.another.timer.5MinuteRate, value = 4.0, group = metered, units = events/second")); verify(output).send(decode("name = t.test.another.timer.15MinuteRate, value = 5.0, group = metered, units = events/second")); }
@Override public void processTimer(MetricName name, Timer timer, String x) throws IOException { processMeter(name, timer, x); final String sanitizedName = sanitizeName(name); final Snapshot snapshot = timer.getSnapshot(); final String durationUnit = timer.durationUnit().name(); printDoubleField(sanitizedName + ".min", timer.min(), "timer", durationUnit); printDoubleField(sanitizedName + ".max", timer.max(), "timer", durationUnit); printDoubleField(sanitizedName + ".mean", timer.mean(), "timer", durationUnit); printDoubleField(sanitizedName + ".stddev", timer.stdDev(), "timer", durationUnit); printDoubleField(sanitizedName + ".median", snapshot.getMedian(), "timer", durationUnit); printDoubleField(sanitizedName + ".75percentile", snapshot.get75thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".95percentile", snapshot.get95thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".98percentile", snapshot.get98thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".99percentile", snapshot.get99thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".999percentile", snapshot.get999thPercentile(), "timer", durationUnit); }
BundleReporter extends AbstractPollingReporter implements MetricProcessor<String>, AutoCloseable { @Override public void processTimer(MetricName name, Timer timer, String x) throws IOException { processMeter(name, timer, x); final String sanitizedName = sanitizeName(name); final Snapshot snapshot = timer.getSnapshot(); final String durationUnit = timer.durationUnit().name(); printDoubleField(sanitizedName + ".min", timer.min(), "timer", durationUnit); printDoubleField(sanitizedName + ".max", timer.max(), "timer", durationUnit); printDoubleField(sanitizedName + ".mean", timer.mean(), "timer", durationUnit); printDoubleField(sanitizedName + ".stddev", timer.stdDev(), "timer", durationUnit); printDoubleField(sanitizedName + ".median", snapshot.getMedian(), "timer", durationUnit); printDoubleField(sanitizedName + ".75percentile", snapshot.get75thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".95percentile", snapshot.get95thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".98percentile", snapshot.get98thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".99percentile", snapshot.get99thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".999percentile", snapshot.get999thPercentile(), "timer", durationUnit); } }
BundleReporter extends AbstractPollingReporter implements MetricProcessor<String>, AutoCloseable { @Override public void processTimer(MetricName name, Timer timer, String x) throws IOException { processMeter(name, timer, x); final String sanitizedName = sanitizeName(name); final Snapshot snapshot = timer.getSnapshot(); final String durationUnit = timer.durationUnit().name(); printDoubleField(sanitizedName + ".min", timer.min(), "timer", durationUnit); printDoubleField(sanitizedName + ".max", timer.max(), "timer", durationUnit); printDoubleField(sanitizedName + ".mean", timer.mean(), "timer", durationUnit); printDoubleField(sanitizedName + ".stddev", timer.stdDev(), "timer", durationUnit); printDoubleField(sanitizedName + ".median", snapshot.getMedian(), "timer", durationUnit); printDoubleField(sanitizedName + ".75percentile", snapshot.get75thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".95percentile", snapshot.get95thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".98percentile", snapshot.get98thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".99percentile", snapshot.get99thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".999percentile", snapshot.get999thPercentile(), "timer", durationUnit); } @JsonCreator  BundleReporter(@JsonProperty("output") TaskDataOutput output,
                          @JsonProperty("name")   AutoField name,
                          @JsonProperty("value")  AutoField value,
                          @JsonProperty("group")  AutoField group,
                          @JsonProperty("units")  AutoField units,
                          @Time(TimeUnit.NANOSECONDS)
                          @JsonProperty("period") long period);  BundleReporter(TaskDataOutput output,
                          AutoField name,
                          AutoField value,
                          AutoField group,
                          AutoField units,
                          long period,
                          TimeUnit periodUnit,
                          MetricsRegistry metricsRegistry); }
BundleReporter extends AbstractPollingReporter implements MetricProcessor<String>, AutoCloseable { @Override public void processTimer(MetricName name, Timer timer, String x) throws IOException { processMeter(name, timer, x); final String sanitizedName = sanitizeName(name); final Snapshot snapshot = timer.getSnapshot(); final String durationUnit = timer.durationUnit().name(); printDoubleField(sanitizedName + ".min", timer.min(), "timer", durationUnit); printDoubleField(sanitizedName + ".max", timer.max(), "timer", durationUnit); printDoubleField(sanitizedName + ".mean", timer.mean(), "timer", durationUnit); printDoubleField(sanitizedName + ".stddev", timer.stdDev(), "timer", durationUnit); printDoubleField(sanitizedName + ".median", snapshot.getMedian(), "timer", durationUnit); printDoubleField(sanitizedName + ".75percentile", snapshot.get75thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".95percentile", snapshot.get95thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".98percentile", snapshot.get98thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".99percentile", snapshot.get99thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".999percentile", snapshot.get999thPercentile(), "timer", durationUnit); } @JsonCreator  BundleReporter(@JsonProperty("output") TaskDataOutput output,
                          @JsonProperty("name")   AutoField name,
                          @JsonProperty("value")  AutoField value,
                          @JsonProperty("group")  AutoField group,
                          @JsonProperty("units")  AutoField units,
                          @Time(TimeUnit.NANOSECONDS)
                          @JsonProperty("period") long period);  BundleReporter(TaskDataOutput output,
                          AutoField name,
                          AutoField value,
                          AutoField group,
                          AutoField units,
                          long period,
                          TimeUnit periodUnit,
                          MetricsRegistry metricsRegistry); void start(); @Override void close(); @Override void run(); @Override void processGauge(MetricName name, Gauge<?> gauge, String x); @Override void processCounter(MetricName name, Counter counter, String x); @Override void processMeter(MetricName name, Metered meter, String x); @Override void processHistogram(MetricName name, Histogram histogram, String x); @Override void processTimer(MetricName name, Timer timer, String x); }
BundleReporter extends AbstractPollingReporter implements MetricProcessor<String>, AutoCloseable { @Override public void processTimer(MetricName name, Timer timer, String x) throws IOException { processMeter(name, timer, x); final String sanitizedName = sanitizeName(name); final Snapshot snapshot = timer.getSnapshot(); final String durationUnit = timer.durationUnit().name(); printDoubleField(sanitizedName + ".min", timer.min(), "timer", durationUnit); printDoubleField(sanitizedName + ".max", timer.max(), "timer", durationUnit); printDoubleField(sanitizedName + ".mean", timer.mean(), "timer", durationUnit); printDoubleField(sanitizedName + ".stddev", timer.stdDev(), "timer", durationUnit); printDoubleField(sanitizedName + ".median", snapshot.getMedian(), "timer", durationUnit); printDoubleField(sanitizedName + ".75percentile", snapshot.get75thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".95percentile", snapshot.get95thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".98percentile", snapshot.get98thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".99percentile", snapshot.get99thPercentile(), "timer", durationUnit); printDoubleField(sanitizedName + ".999percentile", snapshot.get999thPercentile(), "timer", durationUnit); } @JsonCreator  BundleReporter(@JsonProperty("output") TaskDataOutput output,
                          @JsonProperty("name")   AutoField name,
                          @JsonProperty("value")  AutoField value,
                          @JsonProperty("group")  AutoField group,
                          @JsonProperty("units")  AutoField units,
                          @Time(TimeUnit.NANOSECONDS)
                          @JsonProperty("period") long period);  BundleReporter(TaskDataOutput output,
                          AutoField name,
                          AutoField value,
                          AutoField group,
                          AutoField units,
                          long period,
                          TimeUnit periodUnit,
                          MetricsRegistry metricsRegistry); void start(); @Override void close(); @Override void run(); @Override void processGauge(MetricName name, Gauge<?> gauge, String x); @Override void processCounter(MetricName name, Counter counter, String x); @Override void processMeter(MetricName name, Metered meter, String x); @Override void processHistogram(MetricName name, Histogram histogram, String x); @Override void processTimer(MetricName name, Timer timer, String x);  }