/** * Starts the reporter polling at the given period. * * @param period the amount of time between polls * @param unit the unit for {@code period} */ public void start(long period, TimeUnit unit) { start(period, period, unit); }
/** * Starts the reporter polling at the given period. * * @param initialDelay the time to delay the first execution * @param period the amount of time between polls * @param unit the unit for {@code period} and {@code initialDelay} */ synchronized public void start(long initialDelay, long period, TimeUnit unit) { start(initialDelay, period, unit, () -> { try { report(); } catch (Throwable ex) { LOG.error("Exception thrown from {}#report. Exception was suppressed.", ScheduledReporter.this.getClass().getSimpleName(), ex); } }); }
@Override public void close() { this.reporter.stop(); }
scheduledReporter.report();
@Override public void close() { try { this.metricContext.removeNotificationTarget(this.notificationTargetKey); report(); this.closer.close(); } catch (Exception e) { LOGGER.warn("Exception when closing EventReporter", e); } finally { super.close(); } }
@Override protected String getRateUnit() { // Make it "events per rate_unit" to be accurate. return "events/" + super.getRateUnit(); }
/** * Stops the reporter and shuts down its thread of execution. */ @Override public void close() { stop(); }
@Override public void report() { // we do not need to lock here, because the dropwizard registry is // internally a concurrent map @SuppressWarnings("rawtypes") final SortedMap<String, com.codahale.metrics.Gauge> gauges = registry.getGauges(); final SortedMap<String, com.codahale.metrics.Counter> counters = registry.getCounters(); final SortedMap<String, com.codahale.metrics.Histogram> histograms = registry.getHistograms(); final SortedMap<String, com.codahale.metrics.Meter> meters = registry.getMeters(); final SortedMap<String, com.codahale.metrics.Timer> timers = registry.getTimers(); this.reporter.report(gauges, counters, histograms, meters, timers); }
@Override public void close() { this.producer.close(); super.close(); }
@Override protected String getRateUnit() { return "events/" + super.getRateUnit(); }
@Override public void start() { if (reporter != null) { LOG.debug("Starting..."); reporter.start(reportingPeriod, reportingPeriodUnit); } else { throw new IllegalStateException("Attempt to start without preparing " + getClass().getSimpleName()); } }
@Override public void stop() { if (reporter != null) { LOG.debug("Stopping..."); reporter.stop(); } else { throw new IllegalStateException("Attempt to stop without preparing " + getClass().getSimpleName()); } } }
reporterFactory.build(metrics).report();
@Override public void close() { super.close(); for (RrdDb cur : dbPerMetric.values()) { try { cur.close(); } catch (IOException e) { LOG.error("unable to close: " + cur.getPath(), e); } } dbPerMetric.clear(); }