InfluxDbReporter extends ScheduledReporter { @Override public void report( final SortedMap<String, Gauge> gauges, final SortedMap<String, Counter> counters, final SortedMap<String, Histogram> histograms, final SortedMap<String, Meter> meters, final SortedMap<String, Timer> timers) { final long now = System.currentTimeMillis(); try { influxDb.flush(); reportGauges(gauges, now); for (Map.Entry<String, Counter> entry : counters.entrySet()) { reportCounter(entry.getKey(), entry.getValue(), now); } for (Map.Entry<String, Histogram> entry : histograms.entrySet()) { reportHistogram(entry.getKey(), entry.getValue(), now); } for (Map.Entry<String, Meter> entry : meters.entrySet()) { reportMeter(entry.getKey(), entry.getValue(), now); } for (Map.Entry<String, Timer> entry : timers.entrySet()) { reportTimer(entry.getKey(), entry.getValue(), now); } if (influxDb.hasSeriesData()) { influxDb.writeData(); } } catch (ConnectException e) { LOGGER.warn("Unable to connect to InfluxDB. Discarding data."); } catch (Exception e) { LOGGER.warn("Unable to report to InfluxDB with error '{}'. Discarding data.", e.getMessage()); } } private  InfluxDbReporter(
        final MetricRegistry registry,
        final InfluxDbSender influxDb,
        final Map<String, String> tags,
        final TimeUnit rateUnit,
        final TimeUnit durationUnit,
        final MetricFilter filter,
        final boolean skipIdleMetrics,
        final boolean groupGauges,
        final Set<String> includeTimerFields,
        final Set<String> includeMeterFields,
        final Map<String, Pattern> measurementMappings,
        final Transformer tagsTransformer
    ); static Builder forRegistry(MetricRegistry registry); @Override void report(
        final SortedMap<String, Gauge> gauges,
        final SortedMap<String, Counter> counters,
        final SortedMap<String, Histogram> histograms,
        final SortedMap<String, Meter> meters,
        final SortedMap<String, Timer> timers);  }
@Test public void shouldCatchExceptions() throws Exception { doThrow(ConnectException.class).when(influxDb).writeData(); reporter.report(map("gauge", gauge((byte) 1)), this.map(), this.map(), this.map(), this.map()); doThrow(IOException.class).when(influxDb).writeData(); reporter.report(map("gauge", gauge((byte) 1)), this.map(), this.map(), this.map(), this.map()); doThrow(RuntimeException.class).when(influxDb).flush(); reporter.report(map("gauge", gauge((byte) 1)), this.map(), this.map(), this.map(), this.map()); }