use of io.dropwizard.metrics.influxdb.data.InfluxDbPoint in project light-4j by networknt.
the class InfluxDbReporter method reportHistogram.
private void reportHistogram(MetricName name, Histogram histogram, long now) {
if (canSkipMetric(name, histogram)) {
return;
}
final Snapshot snapshot = histogram.getSnapshot();
Map<String, String> apiTags = new HashMap<>(name.getTags());
String apiName = apiTags.remove("apiName");
Map<String, String> clientTags = new HashMap<>(name.getTags());
String clientId = clientTags.remove("clientId");
influxDb.appendPoints(new InfluxDbPoint(apiName + "." + name.getKey() + ".count", apiTags, now, format(histogram.getCount())));
influxDb.appendPoints(new InfluxDbPoint(apiName + "." + name.getKey() + ".min", apiTags, now, format(snapshot.getMin())));
influxDb.appendPoints(new InfluxDbPoint(apiName + "." + name.getKey() + ".max", apiTags, now, format(snapshot.getMax())));
influxDb.appendPoints(new InfluxDbPoint(apiName + "." + name.getKey() + ".mean", apiTags, now, format(snapshot.getMean())));
if (clientId != null) {
influxDb.appendPoints(new InfluxDbPoint(clientId + "." + name.getKey() + ".count", clientTags, now, format(histogram.getCount())));
influxDb.appendPoints(new InfluxDbPoint(clientId + "." + name.getKey() + ".min", clientTags, now, format(snapshot.getMin())));
influxDb.appendPoints(new InfluxDbPoint(clientId + "." + name.getKey() + ".max", clientTags, now, format(snapshot.getMax())));
influxDb.appendPoints(new InfluxDbPoint(clientId + "." + name.getKey() + ".mean", clientTags, now, format(snapshot.getMean())));
}
}
use of io.dropwizard.metrics.influxdb.data.InfluxDbPoint in project light-4j by networknt.
the class InfluxDbReporterTest method reportsByteGaugeValues.
@Test
public void reportsByteGaugeValues() throws Exception {
reporter.report(map("gauge", gauge((byte) 1)), this.map(), this.map(), this.map(), this.map());
final ArgumentCaptor<InfluxDbPoint> influxDbPointCaptor = ArgumentCaptor.forClass(InfluxDbPoint.class);
Mockito.verify(influxDb, atLeastOnce()).appendPoints(influxDbPointCaptor.capture());
InfluxDbPoint point = influxDbPointCaptor.getValue();
/*
assertThat(point.getMeasurement()).isEqualTo("gauge");
assertThat(point.getFields()).isNotEmpty();
assertThat(point.getFields()).hasSize(1);
assertThat(point.getFields()).contains(entry("value", (byte) 1));
*/
}
use of io.dropwizard.metrics.influxdb.data.InfluxDbPoint in project light-4j by networknt.
the class InfluxDbReporterTest method reportsMeters.
@Test
public void reportsMeters() throws Exception {
final Meter meter = mock(Meter.class);
when(meter.getCount()).thenReturn(1L);
when(meter.getOneMinuteRate()).thenReturn(2.0);
when(meter.getFiveMinuteRate()).thenReturn(3.0);
when(meter.getFifteenMinuteRate()).thenReturn(4.0);
when(meter.getMeanRate()).thenReturn(5.0);
reporter.report(this.map(), this.map(), this.map(), this.map("meter", meter), this.map());
final ArgumentCaptor<InfluxDbPoint> influxDbPointCaptor = ArgumentCaptor.forClass(InfluxDbPoint.class);
Mockito.verify(influxDb, atLeastOnce()).appendPoints(influxDbPointCaptor.capture());
InfluxDbPoint point = influxDbPointCaptor.getValue();
/*
assertThat(point.getMeasurement()).isEqualTo("meter");
assertThat(point.getFields()).isNotEmpty();
assertThat(point.getFields()).hasSize(5);
assertThat(point.getFields()).contains(entry("count", 1L));
assertThat(point.getFields()).contains(entry("one-minute", 2.0));
assertThat(point.getFields()).contains(entry("five-minute", 3.0));
assertThat(point.getFields()).contains(entry("fifteen-minute", 4.0));
assertThat(point.getFields()).contains(entry("mean-rate", 5.0));
*/
}
use of io.dropwizard.metrics.influxdb.data.InfluxDbPoint in project light-4j by networknt.
the class InfluxDbReporterTest method reportsTimers.
@Test
public void reportsTimers() throws Exception {
final Timer timer = mock(Timer.class);
when(timer.getCount()).thenReturn(1L);
when(timer.getMeanRate()).thenReturn(2.0);
when(timer.getOneMinuteRate()).thenReturn(3.0);
when(timer.getFiveMinuteRate()).thenReturn(4.0);
when(timer.getFifteenMinuteRate()).thenReturn(5.0);
final Snapshot snapshot = mock(Snapshot.class);
when(snapshot.getMin()).thenReturn(TimeUnit.MILLISECONDS.toNanos(100));
when(snapshot.getMean()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(200));
when(snapshot.getMax()).thenReturn(TimeUnit.MILLISECONDS.toNanos(300));
when(snapshot.getStdDev()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(400));
when(snapshot.getMedian()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(500));
when(snapshot.get75thPercentile()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(600));
when(snapshot.get95thPercentile()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(700));
when(snapshot.get98thPercentile()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(800));
when(snapshot.get99thPercentile()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(900));
when(snapshot.get999thPercentile()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(1000));
when(timer.getSnapshot()).thenReturn(snapshot);
reporter.report(this.map(), this.map(), this.map(), this.map(), map("timer", timer));
final ArgumentCaptor<InfluxDbPoint> influxDbPointCaptor = ArgumentCaptor.forClass(InfluxDbPoint.class);
Mockito.verify(influxDb, atLeastOnce()).appendPoints(influxDbPointCaptor.capture());
InfluxDbPoint point = influxDbPointCaptor.getValue();
/*
assertThat(point.getMeasurement()).isEqualTo("timer");
assertThat(point.getFields()).isNotEmpty();
assertThat(point.getFields()).hasSize(17);
assertThat(point.getFields()).contains(entry("count", 1L));
assertThat(point.getFields()).contains(entry("mean-rate", 2.0));
assertThat(point.getFields()).contains(entry("one-minute", 3.0));
assertThat(point.getFields()).contains(entry("five-minute", 4.0));
assertThat(point.getFields()).contains(entry("fifteen-minute", 5.0));
assertThat(point.getFields()).contains(entry("min", 100.0));
assertThat(point.getFields()).contains(entry("mean", 200.0));
assertThat(point.getFields()).contains(entry("max", 300.0));
assertThat(point.getFields()).contains(entry("std-dev", 400.0));
assertThat(point.getFields()).contains(entry("median", 500.0));
assertThat(point.getFields()).contains(entry("75-percentile", 600.0));
assertThat(point.getFields()).contains(entry("95-percentile", 700.0));
assertThat(point.getFields()).contains(entry("98-percentile", 800.0));
assertThat(point.getFields()).contains(entry("99-percentile", 900.0));
assertThat(point.getFields()).contains(entry("999-percentile", 1000.0));
*/
}
Aggregations