@Test public void reportsMeterValues() throws Exception { final Meter meter = mock(Meter.class); when(meter.eventType()).thenReturn("events"); when(meter.rateUnit()).thenReturn(TimeUnit.SECONDS); when(meter.count()).thenReturn(1L); when(meter.meanRate()).thenReturn(2.0); when(meter.oneMinuteRate()).thenReturn(3.0); when(meter.fiveMinuteRate()).thenReturn(4.0); when(meter.fifteenMinuteRate()).thenReturn(5.0); reporter.processMeter(name("meter"), meter, null); verify(output).send(decode("name = t.test.meter.count, value = 1, group = metered, units = events")); verify(output).send(decode("name = t.test.meter.meanRate, value = 2.0, group = metered, units = events/second")); verify(output).send(decode("name = t.test.meter.1MinuteRate, value = 3.0, group = metered, units = events/second")); verify(output).send(decode("name = t.test.meter.5MinuteRate, value = 4.0, group = metered, units = events/second")); verify(output).send(decode("name = t.test.meter.15MinuteRate, value = 5.0, group = metered, units = events/second")); }
@Override public void processMeter(MetricName name, Metered meter, String x) throws IOException { final String sanitizedName = sanitizeName(name); final String rateUnits = meter.rateUnit().name(); final String rateUnit = rateUnits.substring(0, rateUnits.length() - 1).toLowerCase(Locale.US); final String unit = meter.eventType() + '/' + rateUnit; printLongField(sanitizedName + ".count", meter.count(), "metered", meter.eventType()); printDoubleField(sanitizedName + ".meanRate", meter.meanRate(), "metered", unit); printDoubleField(sanitizedName + ".1MinuteRate", meter.oneMinuteRate(), "metered", unit); printDoubleField(sanitizedName + ".5MinuteRate", meter.fiveMinuteRate(), "metered", unit); printDoubleField(sanitizedName + ".15MinuteRate", meter.fifteenMinuteRate(), "metered", unit); }
BundleReporter extends AbstractPollingReporter implements MetricProcessor<String>, AutoCloseable { @Override public void processMeter(MetricName name, Metered meter, String x) throws IOException { final String sanitizedName = sanitizeName(name); final String rateUnits = meter.rateUnit().name(); final String rateUnit = rateUnits.substring(0, rateUnits.length() - 1).toLowerCase(Locale.US); final String unit = meter.eventType() + '/' + rateUnit; printLongField(sanitizedName + ".count", meter.count(), "metered", meter.eventType()); printDoubleField(sanitizedName + ".meanRate", meter.meanRate(), "metered", unit); printDoubleField(sanitizedName + ".1MinuteRate", meter.oneMinuteRate(), "metered", unit); printDoubleField(sanitizedName + ".5MinuteRate", meter.fiveMinuteRate(), "metered", unit); printDoubleField(sanitizedName + ".15MinuteRate", meter.fifteenMinuteRate(), "metered", unit); } }
BundleReporter extends AbstractPollingReporter implements MetricProcessor<String>, AutoCloseable { @Override public void processMeter(MetricName name, Metered meter, String x) throws IOException { final String sanitizedName = sanitizeName(name); final String rateUnits = meter.rateUnit().name(); final String rateUnit = rateUnits.substring(0, rateUnits.length() - 1).toLowerCase(Locale.US); final String unit = meter.eventType() + '/' + rateUnit; printLongField(sanitizedName + ".count", meter.count(), "metered", meter.eventType()); printDoubleField(sanitizedName + ".meanRate", meter.meanRate(), "metered", unit); printDoubleField(sanitizedName + ".1MinuteRate", meter.oneMinuteRate(), "metered", unit); printDoubleField(sanitizedName + ".5MinuteRate", meter.fiveMinuteRate(), "metered", unit); printDoubleField(sanitizedName + ".15MinuteRate", meter.fifteenMinuteRate(), "metered", unit); } @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 processMeter(MetricName name, Metered meter, String x) throws IOException { final String sanitizedName = sanitizeName(name); final String rateUnits = meter.rateUnit().name(); final String rateUnit = rateUnits.substring(0, rateUnits.length() - 1).toLowerCase(Locale.US); final String unit = meter.eventType() + '/' + rateUnit; printLongField(sanitizedName + ".count", meter.count(), "metered", meter.eventType()); printDoubleField(sanitizedName + ".meanRate", meter.meanRate(), "metered", unit); printDoubleField(sanitizedName + ".1MinuteRate", meter.oneMinuteRate(), "metered", unit); printDoubleField(sanitizedName + ".5MinuteRate", meter.fiveMinuteRate(), "metered", unit); printDoubleField(sanitizedName + ".15MinuteRate", meter.fifteenMinuteRate(), "metered", unit); } @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 processMeter(MetricName name, Metered meter, String x) throws IOException { final String sanitizedName = sanitizeName(name); final String rateUnits = meter.rateUnit().name(); final String rateUnit = rateUnits.substring(0, rateUnits.length() - 1).toLowerCase(Locale.US); final String unit = meter.eventType() + '/' + rateUnit; printLongField(sanitizedName + ".count", meter.count(), "metered", meter.eventType()); printDoubleField(sanitizedName + ".meanRate", meter.meanRate(), "metered", unit); printDoubleField(sanitizedName + ".1MinuteRate", meter.oneMinuteRate(), "metered", unit); printDoubleField(sanitizedName + ".5MinuteRate", meter.fiveMinuteRate(), "metered", unit); printDoubleField(sanitizedName + ".15MinuteRate", meter.fifteenMinuteRate(), "metered", unit); } @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);  }