import com.codahale.metrics.ScheduledReporter;
public class SendToLocalInfluxDB {
public static void main(String[] args) {
ScheduledReporter r0 = null;
ScheduledReporter r1 = null;
try {
final MetricRegistry registry = new MetricRegistry();
r0 = startConsoleReporter(registry);
r1 = startInfluxdbReporter(registry);
final Meter mymeter0 = registry.meter("MyMeter.0");
for (int i = 0; i < 100; i++) {
mymeter0.mark();
mymeter0.mark(Math.round(Math.random() * 100.0));
Thread.sleep(Math.round(Math.random() * 1000.0));
}
} catch (Exception exc) {
exc.printStackTrace();
System.exit(1);
} finally {
if (r1 != null) {
r1.report();
r1.stop();
}
if (r0 != null) {
r0.report();
r0.stop();
}