com.twitter.common.stats
Class NumericStatExporter

java.lang.Object
  extended by com.twitter.common.stats.NumericStatExporter

public class NumericStatExporter
extends Object

Stat exporter that extracts numeric Stats from the Stats system, and exports them via a caller-defined sink.


Field Summary
static Function<Stat<?>,String> GET_NAME
           
static Function<Stat<? extends Number>,Number> READ_STAT
           
 
Constructor Summary
NumericStatExporter(Closure<Map<String,? extends Number>> exportSink, ScheduledExecutorService executor, Amount<Long,Time> exportInterval)
          Creates a new numeric stat exporter that will export to the specified sink.
 
Method Summary
 void start(ShutdownRegistry shutdownRegistry)
          Starts the stat exporter.
 void stop()
          Stops the stat exporter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GET_NAME

public static final Function<Stat<?>,String> GET_NAME

READ_STAT

public static final Function<Stat<? extends Number>,Number> READ_STAT
Constructor Detail

NumericStatExporter

public NumericStatExporter(Closure<Map<String,? extends Number>> exportSink,
                           ScheduledExecutorService executor,
                           Amount<Long,Time> exportInterval)
Creates a new numeric stat exporter that will export to the specified sink.

Parameters:
exportSink - Consumes stats.
executor - Executor to handle export thread.
exportInterval - Export period.
Method Detail

start

public void start(ShutdownRegistry shutdownRegistry)
Starts the stat exporter.

Parameters:
shutdownRegistry - Shutdown hook registry to allow the exporter to cleanly halt.

stop

public void stop()
Stops the stat exporter. Once stopped, it may be started again by calling start(ShutdownRegistry).