InfluxDbReporter extends ScheduledMetrics2Reporter { @Override public void reportMetrics(Map<MetricName, Gauge> gauges, Map<MetricName, Counter> counters, Map<MetricName, Histogram> histograms, Map<MetricName, Meter> meters, Map<MetricName, Timer> timers) { final Timer.Context time = registry.timer(reportingTimeMetricName).time(); long timestamp = clock.getTime(); reportGauges(gauges, timestamp); reportCounter(counters, timestamp); reportHistograms(histograms, timestamp); reportMeters(meters, timestamp); reportTimers(timers, timestamp); flush(); time.stop(); } private  InfluxDbReporter(Builder builder); static Builder forRegistry(Metric2Registry registry, CorePlugin corePlugin); @Override void reportMetrics(Map<MetricName, Gauge> gauges,
							  Map<MetricName, Counter> counters,
							  Map<MetricName, Histogram> histograms,
							  Map<MetricName, Meter> meters,
							  Map<MetricName, Timer> timers); static String getInfluxDbLineProtocolString(MetricName metricName);  }
@Test public void testReportNullGauge() throws Exception { influxDbReporter.reportMetrics( metricNameMap(name("cpu_usage").type("user").tag("core", "1").build(), gauge(null)), metricNameMap(Counter.class), metricNameMap(Histogram.class), metricNameMap(Meter.class), metricNameMap(Timer.class)); verify(httpClient).send(eq("POST"), eq("http: eq(Collections.emptyList())); }
@Test public void testReportBooleanGauge() throws Exception { influxDbReporter.reportMetrics( metricNameMap(name("gauge").build(), gauge(true)), metricNameMap(Counter.class), metricNameMap(Histogram.class), metricNameMap(Meter.class), metricNameMap(Timer.class)); verify(httpClient).send(eq("POST"), eq("http: eq(singletonList(format("gauge,app=test value_boolean=true %d", timestamp)))); }
@Test public void testReportStringGauge() throws Exception { influxDbReporter.reportMetrics( metricNameMap(name("gauge").build(), gauge("foo")), metricNameMap(Counter.class), metricNameMap(Histogram.class), metricNameMap(Meter.class), metricNameMap(Timer.class)); verify(httpClient).send(eq("POST"), eq("http: eq(singletonList(format("gauge,app=test value_string=\"foo\" %d", timestamp)))); }
@Test public void testReportGaugesExponent() throws Exception { influxDbReporter.reportMetrics( metricNameMap(name("cpu_usage").type("user").tag("core", "1").build(), gauge(1e-8)), metricNameMap(Counter.class), metricNameMap(Histogram.class), metricNameMap(Meter.class), metricNameMap(Timer.class)); verify(httpClient).send(eq("POST"), eq("http: eq(singletonList(format("cpu_usage,core=1,type=user,app=test value=1.0e-8 %d", timestamp)))); }
@Test public void testReportCounters() throws Exception { influxDbReporter.reportMetrics( metricNameMap(Gauge.class), metricNameMap(name("web_sessions").build(), counter(123)), metricNameMap(Histogram.class), metricNameMap(Meter.class), metricNameMap(Timer.class)); verify(httpClient).send(eq("POST"), eq("http: eq(singletonList(format("web_sessions,app=test count=123i %d", timestamp)))); }