Class Slf4jReporter

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class Slf4jReporter
    extends ScheduledReporter
    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.
    • Field Detail

      • logger

        private final org.slf4j.Logger logger
      • marker

        private final org.slf4j.Marker marker
    • 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

      • 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 class ScheduledReporter
        Parameters:
        gauges - all of the gauges in the registry
        counters - all of the counters in the registry
        histograms - all of the histograms in the registry
        meters - all of the meters in the registry
        timers - 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)