Package com.codahale.metrics
Class ScheduledReporter
java.lang.Object
com.codahale.metrics.ScheduledReporter
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
ConsoleReporter
,CsvReporter
,GraphiteReporter
,Slf4jReporter
The abstract base class for all scheduled reporters (i.e., reporters which process a registry's
metrics periodically).
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
A simple named thread factory. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final double
private final String
private final ScheduledExecutorService
private final MetricFilter
private final double
private final String
private final MetricRegistry
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ScheduledReporter
(MetricRegistry registry, String name, MetricFilter filter, TimeUnit rateUnit, TimeUnit durationUnit) Creates a newScheduledReporter
instance. -
Method Summary
Modifier and TypeMethodDescriptionprivate String
calculateRateUnit
(TimeUnit unit) void
close()
Stops the reporter and shuts down its thread of execution.protected double
convertDuration
(double duration) protected double
convertRate
(double rate) protected String
protected String
void
report()
Report the current values of all metrics in the registry.abstract void
report
(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) Called periodically by the polling thread.void
Starts the reporter polling at the given period.void
stop()
Stops the reporter and shuts down its thread of execution.
-
Field Details
-
registry
-
executor
-
filter
-
durationFactor
private final double durationFactor -
durationUnit
-
rateFactor
private final double rateFactor -
rateUnit
-
-
Constructor Details
-
ScheduledReporter
protected ScheduledReporter(MetricRegistry registry, String name, MetricFilter filter, TimeUnit rateUnit, TimeUnit durationUnit) Creates a newScheduledReporter
instance.- Parameters:
registry
- theMetricRegistry
containing the metrics this reporter will reportname
- the reporter's namefilter
- the filter for which metrics to report
-
-
Method Details
-
start
Starts the reporter polling at the given period.- Parameters:
period
- the amount of time between pollsunit
- the unit forperiod
-
stop
public void stop()Stops the reporter and shuts down its thread of execution. -
close
public void close()Stops the reporter and shuts down its thread of execution.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
report
public void report()Report the current values of all metrics in the registry. -
report
public abstract void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, 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
protected double convertDuration(double duration) -
convertRate
protected double convertRate(double rate) -
calculateRateUnit
-