Package io.dropwizard.metrics5
Class ScheduledReporter
java.lang.Object
io.dropwizard.metrics5.ScheduledReporter
- All Implemented Interfaces:
Reporter,Closeable,AutoCloseable
- Direct Known Subclasses:
ConsoleReporter,CsvReporter,Slf4jReporter
The abstract base class for all scheduled reporters (i.e., reporters which process a registry's
metrics periodically).
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedScheduledReporter(MetricRegistry registry, String name, MetricFilter filter, TimeUnit rateUnit, TimeUnit durationUnit) Creates a newScheduledReporterinstance.protectedScheduledReporter(MetricRegistry registry, String name, MetricFilter filter, TimeUnit rateUnit, TimeUnit durationUnit, ScheduledExecutorService executor) Creates a newScheduledReporterinstance.protectedScheduledReporter(MetricRegistry registry, String name, MetricFilter filter, TimeUnit rateUnit, TimeUnit durationUnit, ScheduledExecutorService executor, boolean shutdownExecutorOnStop) Creates a newScheduledReporterinstance.protectedScheduledReporter(MetricRegistry registry, String name, MetricFilter filter, TimeUnit rateUnit, TimeUnit durationUnit, ScheduledExecutorService executor, boolean shutdownExecutorOnStop, Set<MetricAttribute> disabledMetricAttributes) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Stops the reporter and shuts down its thread of execution.doubleconvertDuration(double duration) doubleconvertRate(double rate) protected ScheduledFuture<?>getScheduledFuture(long initialDelay, long period, TimeUnit unit, Runnable runnable) Deprecated.protected ScheduledFuture<?>getScheduledFuture(long initialDelay, long period, TimeUnit unit, Runnable runnable, ScheduledExecutorService executor) Schedule the task, and return a future.booleanvoidreport()Report the current values of all metrics in the registry.abstract voidreport(SortedMap<MetricName, Gauge<?>> gauges, SortedMap<MetricName, Counter> counters, SortedMap<MetricName, Histogram> histograms, SortedMap<MetricName, Meter> meters, SortedMap<MetricName, Timer> timers) Called periodically by the polling thread.voidStarts the reporter polling at the given period.voidStarts the reporter polling at the given period.voidstop()Stops the reporter and if shutdownExecutorOnStop is true then shuts down its thread of execution.
-
Constructor Details
-
ScheduledReporter
protected ScheduledReporter(MetricRegistry registry, String name, MetricFilter filter, TimeUnit rateUnit, TimeUnit durationUnit) Creates a newScheduledReporterinstance.- Parameters:
registry- theMetricRegistrycontaining the metrics this reporter will reportname- the reporter's namefilter- the filter for which metrics to reportrateUnit- a unit of timedurationUnit- a unit of time
-
ScheduledReporter
protected ScheduledReporter(MetricRegistry registry, String name, MetricFilter filter, TimeUnit rateUnit, TimeUnit durationUnit, ScheduledExecutorService executor) Creates a newScheduledReporterinstance.- Parameters:
registry- theMetricRegistrycontaining the metrics this reporter will reportname- the reporter's namefilter- the filter for which metrics to reportexecutor- the executor to use while scheduling reporting of metrics.
-
ScheduledReporter
protected ScheduledReporter(MetricRegistry registry, String name, MetricFilter filter, TimeUnit rateUnit, TimeUnit durationUnit, ScheduledExecutorService executor, boolean shutdownExecutorOnStop) Creates a newScheduledReporterinstance.- Parameters:
registry- theMetricRegistrycontaining the metrics this reporter will reportname- the reporter's namefilter- the filter for which metrics to reportexecutor- the executor to use while scheduling reporting of metrics.shutdownExecutorOnStop- if true, then executor will be stopped in same time with this reporter
-
ScheduledReporter
protected ScheduledReporter(MetricRegistry registry, String name, MetricFilter filter, TimeUnit rateUnit, TimeUnit durationUnit, ScheduledExecutorService executor, boolean shutdownExecutorOnStop, Set<MetricAttribute> disabledMetricAttributes)
-
-
Method Details
-
start
Starts the reporter polling at the given period.- Parameters:
period- the amount of time between pollsunit- the unit forperiod
-
getScheduledFuture
@Deprecated protected ScheduledFuture<?> getScheduledFuture(long initialDelay, long period, TimeUnit unit, Runnable runnable) Deprecated.Schedule the task, and return a future. -
getScheduledFuture
protected ScheduledFuture<?> getScheduledFuture(long initialDelay, long period, TimeUnit unit, Runnable runnable, ScheduledExecutorService executor) Schedule the task, and return a future. The current implementation uses scheduleWithFixedDelay, replacing scheduleWithFixedRate. This avoids queueing issues, but may cause some reporters to skip metrics, as scheduleWithFixedDelay introduces a growing delta from the original start point. Overriding this in a subclass to revert to the old behavior is permitted. -
start
Starts the reporter polling at the given period.- Parameters:
initialDelay- the time to delay the first executionperiod- the amount of time between pollsunit- the unit forperiodandinitialDelay
-
stop
public void stop()Stops the reporter and if shutdownExecutorOnStop is true then shuts down its thread of execution.Uses the shutdown pattern from http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ExecutorService.html
-
close
public void close()Stops the reporter and shuts down its thread of execution.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
report
public void report()Report the current values of all metrics in the registry. -
report
public abstract void report(SortedMap<MetricName, Gauge<?>> gauges, SortedMap<MetricName, Counter> counters, SortedMap<MetricName, Histogram> histograms, SortedMap<MetricName, Meter> meters, SortedMap<MetricName, Timer> timers) Called periodically by the polling thread. Subclasses should report all the given metrics.- Parameters:
gauges- all of the gauges in the registrycounters- all of the counters in the registryhistograms- all of the histograms in the registrymeters- all of the meters in the registrytimers- all of the timers in the registry
-
getRateUnit
-
getDurationUnit
-
convertDuration
public double convertDuration(double duration) -
convertRate
public double convertRate(double rate) -
isShutdownExecutorOnStop
public boolean isShutdownExecutorOnStop() -
getDisabledMetricAttributes
-
getScheduledFuture(long, long, TimeUnit, Runnable, ScheduledExecutorService)instead.