com.yammer.metrics.reporting
Class ConsoleReporter

java.lang.Object
  extended by com.yammer.metrics.reporting.AbstractReporter
      extended by com.yammer.metrics.reporting.AbstractPollingReporter
          extended by com.yammer.metrics.reporting.ConsoleReporter
All Implemented Interfaces:
MetricsProcessor<PrintStream>, Runnable

public class ConsoleReporter
extends AbstractPollingReporter
implements MetricsProcessor<PrintStream>

A simple reporters which prints out application metrics to a PrintStream periodically.


Field Summary
 
Fields inherited from class com.yammer.metrics.reporting.AbstractReporter
metricsRegistry
 
Constructor Summary
ConsoleReporter(MetricsRegistry metricsRegistry, PrintStream out, MetricPredicate predicate)
          Creates a new ConsoleReporter for a given metrics registry.
ConsoleReporter(MetricsRegistry metricsRegistry, PrintStream out, MetricPredicate predicate, Clock clock, TimeZone timeZone)
          Creates a new ConsoleReporter for a given metrics registry.
ConsoleReporter(MetricsRegistry metricsRegistry, PrintStream out, MetricPredicate predicate, Clock clock, TimeZone timeZone, Locale locale)
          Creates a new ConsoleReporter for a given metrics registry.
ConsoleReporter(PrintStream out)
          Creates a new ConsoleReporter for the default metrics registry, with unrestricted output.
 
Method Summary
static void enable(long period, TimeUnit unit)
          Enables the console reporter for the default metrics registry, and causes it to print to STDOUT with the specified period.
static void enable(MetricsRegistry metricsRegistry, long period, TimeUnit unit)
          Enables the console reporter for the given metrics registry, and causes it to print to STDOUT with the specified period and unrestricted output.
 void processCounter(MetricName name, CounterMetric counter, PrintStream stream)
           
 void processGauge(MetricName name, GaugeMetric<?> gauge, PrintStream stream)
           
 void processHistogram(MetricName name, HistogramMetric histogram, PrintStream stream)
           
 void processMeter(MetricName name, Metered meter, PrintStream stream)
           
 void processTimer(MetricName name, TimerMetric timer, PrintStream stream)
           
 void run()
           
 
Methods inherited from class com.yammer.metrics.reporting.AbstractPollingReporter
shutdown, shutdown, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConsoleReporter

public ConsoleReporter(PrintStream out)
Creates a new ConsoleReporter for the default metrics registry, with unrestricted output.

Parameters:
out - the PrintStream to which output will be written

ConsoleReporter

public ConsoleReporter(MetricsRegistry metricsRegistry,
                       PrintStream out,
                       MetricPredicate predicate)
Creates a new ConsoleReporter for a given metrics registry.

Parameters:
metricsRegistry - the metrics registry
out - the PrintStream to which output will be written
predicate - the MetricPredicate used to determine whether a metric will be output

ConsoleReporter

public ConsoleReporter(MetricsRegistry metricsRegistry,
                       PrintStream out,
                       MetricPredicate predicate,
                       Clock clock,
                       TimeZone timeZone)
Creates a new ConsoleReporter for a given metrics registry.

Parameters:
metricsRegistry - the metrics registry
out - the PrintStream to which output will be written
predicate - the MetricPredicate used to determine whether a metric will be output
clock - the Clock used to print time
timeZone - the TimeZone used to print time

ConsoleReporter

public ConsoleReporter(MetricsRegistry metricsRegistry,
                       PrintStream out,
                       MetricPredicate predicate,
                       Clock clock,
                       TimeZone timeZone,
                       Locale locale)
Creates a new ConsoleReporter for a given metrics registry.

Parameters:
metricsRegistry - the metrics registry
out - the PrintStream to which output will be written
predicate - the MetricPredicate used to determine whether a metric will be output
clock - the Clock used to print time
timeZone - the TimeZone used to print time
locale - the Locale used to print values
Method Detail

enable

public static void enable(long period,
                          TimeUnit unit)
Enables the console reporter for the default metrics registry, and causes it to print to STDOUT with the specified period.

Parameters:
period - the period between successive outputs
unit - the time unit of period

enable

public static void enable(MetricsRegistry metricsRegistry,
                          long period,
                          TimeUnit unit)
Enables the console reporter for the given metrics registry, and causes it to print to STDOUT with the specified period and unrestricted output.

Parameters:
metricsRegistry - the metrics registry
period - the period between successive outputs
unit - the time unit of period

run

public void run()
Specified by:
run in interface Runnable

processGauge

public void processGauge(MetricName name,
                         GaugeMetric<?> gauge,
                         PrintStream stream)
Specified by:
processGauge in interface MetricsProcessor<PrintStream>

processCounter

public void processCounter(MetricName name,
                           CounterMetric counter,
                           PrintStream stream)
Specified by:
processCounter in interface MetricsProcessor<PrintStream>

processMeter

public void processMeter(MetricName name,
                         Metered meter,
                         PrintStream stream)
Specified by:
processMeter in interface MetricsProcessor<PrintStream>

processHistogram

public void processHistogram(MetricName name,
                             HistogramMetric histogram,
                             PrintStream stream)
Specified by:
processHistogram in interface MetricsProcessor<PrintStream>

processTimer

public void processTimer(MetricName name,
                         TimerMetric timer,
                         PrintStream stream)
Specified by:
processTimer in interface MetricsProcessor<PrintStream>


Copyright © 2011. All Rights Reserved.