Class Slf4jReporter
java.lang.Object
com.codahale.metrics.ScheduledReporter
com.codahale.metrics.Slf4jReporter
- All Implemented Interfaces:
Closeable, AutoCloseable
A reporter class for logging metrics values to a SLF4J
Logger periodically, similar to
ConsoleReporter or CsvReporter, but using the SLF4J framework instead. It also
supports specifying a Marker instance that can be used by custom appenders and filters
for the bound logging toolkit to further process metrics reports.-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateSlf4jReporter(MetricRegistry registry, org.slf4j.Logger logger, org.slf4j.Marker marker, TimeUnit rateUnit, TimeUnit durationUnit, MetricFilter filter) -
Method Summary
Modifier and TypeMethodDescriptionstatic Slf4jReporter.BuilderforRegistry(MetricRegistry registry) Returns a newSlf4jReporter.BuilderforSlf4jReporter.protected Stringprivate voidlogCounter(String name, Counter counter) private voidprivate voidlogHistogram(String name, Histogram histogram) private voidprivate voidvoidreport(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.Methods inherited from class ScheduledReporter
close, convertDuration, convertRate, getDurationUnit, report, start, stop
-
Field Details
-
logger
private final org.slf4j.Logger logger -
marker
private final org.slf4j.Marker marker
-
-
Constructor Details
-
Slf4jReporter
private Slf4jReporter(MetricRegistry registry, org.slf4j.Logger logger, org.slf4j.Marker marker, TimeUnit rateUnit, TimeUnit durationUnit, MetricFilter filter)
-
-
Method Details
-
forRegistry
Returns a newSlf4jReporter.BuilderforSlf4jReporter.- Parameters:
registry- the registry to report- Returns:
- a
Slf4jReporter.Builderinstance for aSlf4jReporter
-
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:ScheduledReporterCalled periodically by the polling thread. Subclasses should report all the given metrics.- Specified by:
reportin 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
-
logTimer
-
logMeter
-
logHistogram
-
logCounter
-
logGauge
-
getRateUnit
- Overrides:
getRateUnitin classScheduledReporter
-