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:
MetricProcessor<PrintStream>, Runnable

public class ConsoleReporter
extends AbstractPollingReporter
implements MetricProcessor<PrintStream>

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


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, Counter counter, PrintStream stream)
          Process the given counter.
 void processGauge(MetricName name, Gauge<?> gauge, PrintStream stream)
          Process the given gauge.
 void processHistogram(MetricName name, Histogram histogram, PrintStream stream)
          Process the given histogram.
 void processMeter(MetricName name, Metered meter, PrintStream stream)
          Process the given Metered instance.
 void processTimer(MetricName name, Timer timer, PrintStream stream)
          Process the given timer.
 void run()
          The method called when a a poll is scheduled to occur.
 
Methods inherited from class com.yammer.metrics.reporting.AbstractPollingReporter
shutdown, shutdown, start
 
Methods inherited from class com.yammer.metrics.reporting.AbstractReporter
getMetricsRegistry
 
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()
Description copied from class: AbstractPollingReporter
The method called when a a poll is scheduled to occur.

Specified by:
run in interface Runnable
Specified by:
run in class AbstractPollingReporter

processGauge

public void processGauge(MetricName name,
                         Gauge<?> gauge,
                         PrintStream stream)
Description copied from interface: MetricProcessor
Process the given gauge.

Specified by:
processGauge in interface MetricProcessor<PrintStream>
Parameters:
name - the name of the gauge
gauge - the gauge
stream - the context of the meter

processCounter

public void processCounter(MetricName name,
                           Counter counter,
                           PrintStream stream)
Description copied from interface: MetricProcessor
Process the given counter.

Specified by:
processCounter in interface MetricProcessor<PrintStream>
Parameters:
name - the name of the counter
counter - the counter
stream - the context of the meter

processMeter

public void processMeter(MetricName name,
                         Metered meter,
                         PrintStream stream)
Description copied from interface: MetricProcessor
Process the given Metered instance.

Specified by:
processMeter in interface MetricProcessor<PrintStream>
Parameters:
name - the name of the meter
meter - the meter
stream - the context of the meter

processHistogram

public void processHistogram(MetricName name,
                             Histogram histogram,
                             PrintStream stream)
Description copied from interface: MetricProcessor
Process the given histogram.

Specified by:
processHistogram in interface MetricProcessor<PrintStream>
Parameters:
name - the name of the histogram
histogram - the histogram
stream - the context of the meter

processTimer

public void processTimer(MetricName name,
                         Timer timer,
                         PrintStream stream)
Description copied from interface: MetricProcessor
Process the given timer.

Specified by:
processTimer in interface MetricProcessor<PrintStream>
Parameters:
name - the name of the timer
timer - the timer
stream - the context of the meter


Copyright © 2012. All Rights Reserved.