Package com.codahale.metrics.graphite
Class GraphiteReporter
- java.lang.Object
-
- com.codahale.metrics.ScheduledReporter
-
- com.codahale.metrics.graphite.GraphiteReporter
-
- All Implemented Interfaces:
Reporter
,Closeable
,AutoCloseable
public class GraphiteReporter extends ScheduledReporter
A reporter which publishes metric values to a Graphite server.- See Also:
- Graphite - Scalable Realtime Graphing
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GraphiteReporter.Builder
A builder forGraphiteReporter
instances.
-
Constructor Summary
Constructors Modifier Constructor Description protected
GraphiteReporter(MetricRegistry registry, GraphiteSender graphite, Clock clock, String prefix, TimeUnit rateUnit, TimeUnit durationUnit, MetricFilter filter, ScheduledExecutorService executor, boolean shutdownExecutorOnStop, Set<MetricAttribute> disabledMetricAttributes)
Creates a newGraphiteReporter
instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
format(double v)
static GraphiteReporter.Builder
forRegistry(MetricRegistry registry)
Returns a newGraphiteReporter.Builder
forGraphiteReporter
.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
stop()
Stops the reporter and if shutdownExecutorOnStop is true then shuts down its thread of execution.-
Methods inherited from class com.codahale.metrics.ScheduledReporter
close, convertDuration, convertRate, getDisabledMetricAttributes, getDurationUnit, getRateUnit, isShutdownExecutorOnStop, report, start, start
-
-
-
-
Constructor Detail
-
GraphiteReporter
protected GraphiteReporter(MetricRegistry registry, GraphiteSender graphite, Clock clock, String prefix, TimeUnit rateUnit, TimeUnit durationUnit, MetricFilter filter, ScheduledExecutorService executor, boolean shutdownExecutorOnStop, Set<MetricAttribute> disabledMetricAttributes)
Creates a newGraphiteReporter
instance.- Parameters:
registry
- theMetricRegistry
containing the metrics this reporter will reportgraphite
- theGraphiteSender
which is responsible for sending metrics to a Carbon server via a transport protocolclock
- the instance of the time. UseClock.defaultClock()
for the defaultprefix
- the prefix of all metric names (may be null)rateUnit
- the time unit of in which rates will be converteddurationUnit
- the time unit of in which durations will be convertedfilter
- the filter for which metrics to reportexecutor
- the executor to use while scheduling reporting of metrics (may be null).shutdownExecutorOnStop
- if true, then executor will be stopped in same time with this reporter
-
-
Method Detail
-
forRegistry
public static GraphiteReporter.Builder forRegistry(MetricRegistry registry)
Returns a newGraphiteReporter.Builder
forGraphiteReporter
.- Parameters:
registry
- the registry to report- Returns:
- a
GraphiteReporter.Builder
instance for aGraphiteReporter
-
report
public void report(SortedMap<String,Gauge> gauges, SortedMap<String,Counter> counters, SortedMap<String,Histogram> histograms, SortedMap<String,Meter> meters, SortedMap<String,Timer> timers)
Description copied from class:ScheduledReporter
Called periodically by the polling thread. Subclasses should report all the given metrics.- Specified by:
report
in classScheduledReporter
- 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
-
stop
public void stop()
Description copied from class:ScheduledReporter
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
- Overrides:
stop
in classScheduledReporter
-
format
protected String format(double v)
-
-