Package com.codahale.metrics
Class Slf4jReporter
- java.lang.Object
-
- com.codahale.metrics.ScheduledReporter
-
- com.codahale.metrics.Slf4jReporter
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class Slf4jReporter extends ScheduledReporter
A reporter class for logging metrics values to a SLF4JLogger
periodically, similar toConsoleReporter
orCsvReporter
, but using the SLF4J framework instead. It also supports specifying aMarker
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 Modifier and Type Class Description static class
Slf4jReporter.Builder
A builder forCsvReporter
instances.
-
Constructor Summary
Constructors Modifier Constructor Description private
Slf4jReporter(MetricRegistry registry, org.slf4j.Logger logger, org.slf4j.Marker marker, java.util.concurrent.TimeUnit rateUnit, java.util.concurrent.TimeUnit durationUnit, MetricFilter filter)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Slf4jReporter.Builder
forRegistry(MetricRegistry registry)
Returns a newSlf4jReporter.Builder
forSlf4jReporter
.protected java.lang.String
getRateUnit()
private void
logCounter(java.lang.String name, Counter counter)
private void
logGauge(java.lang.String name, Gauge gauge)
private void
logHistogram(java.lang.String name, Histogram histogram)
private void
logMeter(java.lang.String name, Meter meter)
private void
logTimer(java.lang.String name, Timer timer)
void
report(java.util.SortedMap<java.lang.String,Gauge> gauges, java.util.SortedMap<java.lang.String,Counter> counters, java.util.SortedMap<java.lang.String,Histogram> histograms, java.util.SortedMap<java.lang.String,Meter> meters, java.util.SortedMap<java.lang.String,Timer> timers)
Called periodically by the polling thread.-
Methods inherited from class com.codahale.metrics.ScheduledReporter
close, convertDuration, convertRate, getDurationUnit, report, start, stop
-
-
-
-
Constructor Detail
-
Slf4jReporter
private Slf4jReporter(MetricRegistry registry, org.slf4j.Logger logger, org.slf4j.Marker marker, java.util.concurrent.TimeUnit rateUnit, java.util.concurrent.TimeUnit durationUnit, MetricFilter filter)
-
-
Method Detail
-
forRegistry
public static Slf4jReporter.Builder forRegistry(MetricRegistry registry)
Returns a newSlf4jReporter.Builder
forSlf4jReporter
.- Parameters:
registry
- the registry to report- Returns:
- a
Slf4jReporter.Builder
instance for aSlf4jReporter
-
report
public void report(java.util.SortedMap<java.lang.String,Gauge> gauges, java.util.SortedMap<java.lang.String,Counter> counters, java.util.SortedMap<java.lang.String,Histogram> histograms, java.util.SortedMap<java.lang.String,Meter> meters, java.util.SortedMap<java.lang.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
-
logTimer
private void logTimer(java.lang.String name, Timer timer)
-
logMeter
private void logMeter(java.lang.String name, Meter meter)
-
logHistogram
private void logHistogram(java.lang.String name, Histogram histogram)
-
logCounter
private void logCounter(java.lang.String name, Counter counter)
-
logGauge
private void logGauge(java.lang.String name, Gauge gauge)
-
getRateUnit
protected java.lang.String getRateUnit()
- Overrides:
getRateUnit
in classScheduledReporter
-
-