@Test public void reportsDoubleGaugeValues() throws Exception { reporter.processGauge(name("gauge"), gauge(1.1), null); verify(output).send(decode("name = t.test.gauge, value = 1.1, group = gauge, units = \"\"")); }
@Override public void processGauge(MetricName name, Gauge<?> gauge, String x) throws IOException { final Object value = gauge.value(); final Class<?> klass = value.getClass(); if (klass == Integer.class || klass == Long.class) { Number asNumber = (Number) gauge.value(); sendMetricData(sanitizeName(name), create(asNumber.longValue()), "gauge", ""); } else if (klass == Float.class || klass == Double.class) { Number asNumber = (Number) gauge.value(); sendMetricData(sanitizeName(name), create(asNumber.doubleValue()), "gauge", ""); } else { sendMetricData(sanitizeName(name), create(gauge.value().toString()), "gauge", ""); } }
BundleReporter extends AbstractPollingReporter implements MetricProcessor<String>, AutoCloseable { @Override public void processGauge(MetricName name, Gauge<?> gauge, String x) throws IOException { final Object value = gauge.value(); final Class<?> klass = value.getClass(); if (klass == Integer.class || klass == Long.class) { Number asNumber = (Number) gauge.value(); sendMetricData(sanitizeName(name), create(asNumber.longValue()), "gauge", ""); } else if (klass == Float.class || klass == Double.class) { Number asNumber = (Number) gauge.value(); sendMetricData(sanitizeName(name), create(asNumber.doubleValue()), "gauge", ""); } else { sendMetricData(sanitizeName(name), create(gauge.value().toString()), "gauge", ""); } } }
BundleReporter extends AbstractPollingReporter implements MetricProcessor<String>, AutoCloseable { @Override public void processGauge(MetricName name, Gauge<?> gauge, String x) throws IOException { final Object value = gauge.value(); final Class<?> klass = value.getClass(); if (klass == Integer.class || klass == Long.class) { Number asNumber = (Number) gauge.value(); sendMetricData(sanitizeName(name), create(asNumber.longValue()), "gauge", ""); } else if (klass == Float.class || klass == Double.class) { Number asNumber = (Number) gauge.value(); sendMetricData(sanitizeName(name), create(asNumber.doubleValue()), "gauge", ""); } else { sendMetricData(sanitizeName(name), create(gauge.value().toString()), "gauge", ""); } } @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 processGauge(MetricName name, Gauge<?> gauge, String x) throws IOException { final Object value = gauge.value(); final Class<?> klass = value.getClass(); if (klass == Integer.class || klass == Long.class) { Number asNumber = (Number) gauge.value(); sendMetricData(sanitizeName(name), create(asNumber.longValue()), "gauge", ""); } else if (klass == Float.class || klass == Double.class) { Number asNumber = (Number) gauge.value(); sendMetricData(sanitizeName(name), create(asNumber.doubleValue()), "gauge", ""); } else { sendMetricData(sanitizeName(name), create(gauge.value().toString()), "gauge", ""); } } @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 processGauge(MetricName name, Gauge<?> gauge, String x) throws IOException { final Object value = gauge.value(); final Class<?> klass = value.getClass(); if (klass == Integer.class || klass == Long.class) { Number asNumber = (Number) gauge.value(); sendMetricData(sanitizeName(name), create(asNumber.longValue()), "gauge", ""); } else if (klass == Float.class || klass == Double.class) { Number asNumber = (Number) gauge.value(); sendMetricData(sanitizeName(name), create(asNumber.doubleValue()), "gauge", ""); } else { sendMetricData(sanitizeName(name), create(gauge.value().toString()), "gauge", ""); } } @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);  }