use of io.dropwizard.metrics.Gauge in project light-4j by networknt.
the class ConsoleReporterTest method reportsGaugeValues.
@Test
public void reportsGaugeValues() throws Exception {
final Gauge gauge = mock(Gauge.class);
when(gauge.getValue()).thenReturn(1);
reporter.report(map("gauge", gauge), this.map(), this.map(), this.map(), this.map());
assertThat(consoleOutput()).isEqualTo(lines("3/17/13 6:04:36 PM =============================================================", "", "-- Gauges ----------------------------------------------------------------------", "gauge", " value = 1", "", ""));
}
use of io.dropwizard.metrics.Gauge in project light-4j by networknt.
the class InfluxDbReporter method report.
@Override
public void report(final SortedMap<MetricName, Gauge> gauges, final SortedMap<MetricName, Counter> counters, final SortedMap<MetricName, Histogram> histograms, final SortedMap<MetricName, Meter> meters, final SortedMap<MetricName, Timer> timers) {
final long now = System.currentTimeMillis();
if (logger.isDebugEnabled())
logger.debug("InfluxDbReporter report is called with counter size " + counters.size());
try {
influxDb.flush();
for (Map.Entry<MetricName, Gauge> entry : gauges.entrySet()) {
reportGauge(entry.getKey(), entry.getValue(), now);
}
for (Map.Entry<MetricName, Counter> entry : counters.entrySet()) {
reportCounter(entry.getKey(), entry.getValue(), now);
}
for (Map.Entry<MetricName, Histogram> entry : histograms.entrySet()) {
reportHistogram(entry.getKey(), entry.getValue(), now);
}
for (Map.Entry<MetricName, Meter> entry : meters.entrySet()) {
reportMeter(entry.getKey(), entry.getValue(), now);
}
for (Map.Entry<MetricName, Timer> entry : timers.entrySet()) {
reportTimer(entry.getKey(), entry.getValue(), now);
}
if (influxDb.hasSeriesData()) {
influxDb.writeData();
}
// reset counters
for (Map.Entry<MetricName, Counter> entry : counters.entrySet()) {
Counter counter = entry.getValue();
long count = counter.getCount();
counter.dec(count);
}
} catch (Exception e) {
logger.error("Unable to report to InfluxDB. Discarding data.", e);
}
}
use of io.dropwizard.metrics.Gauge in project light-4j by networknt.
the class JvmAttributeGaugeSetTest method hasAGaugeForTheJVMUptime.
@Test
public void hasAGaugeForTheJVMUptime() throws Exception {
final Gauge gauge = (Gauge) gauges.getMetrics().get(MetricName.build("uptime"));
assertThat(gauge.getValue()).isEqualTo(100L);
}
use of io.dropwizard.metrics.Gauge in project light-4j by networknt.
the class InfluxDbReporterTest method gauge.
private <T> Gauge gauge(T value) {
final Gauge gauge = mock(Gauge.class);
when(gauge.getValue()).thenReturn(value);
return gauge;
}
Aggregations