public class CsvReporter extends AbstractPollingReporter implements MetricProcessor<CsvReporter.Context>
Modifier and Type | Class and Description |
---|---|
static interface |
CsvReporter.Context
The context used to output metrics.
|
Constructor and Description |
---|
CsvReporter(MetricsRegistry metricsRegistry,
java.io.File outputDir)
Creates a new
CsvReporter which will write all metrics from the given
MetricsRegistry to CSV files in the given output directory. |
CsvReporter(MetricsRegistry metricsRegistry,
MetricPredicate predicate,
java.io.File outputDir)
Creates a new
CsvReporter which will write metrics from the given
MetricsRegistry which match the given MetricPredicate to CSV files in the
given output directory. |
CsvReporter(MetricsRegistry metricsRegistry,
MetricPredicate predicate,
java.io.File outputDir,
Clock clock)
Creates a new
CsvReporter which will write metrics from the given
MetricsRegistry which match the given MetricPredicate to CSV files in the
given output directory. |
Modifier and Type | Method and Description |
---|---|
protected java.io.PrintStream |
createStreamForMetric(MetricName metricName)
Returns an opened
PrintStream for the given MetricName which outputs data
to a metric-specific .csv file in the output directory. |
static void |
enable(java.io.File outputDir,
long period,
java.util.concurrent.TimeUnit unit)
Enables the CSV reporter for the default metrics registry, and causes it to write to files in
outputDir with the specified period. |
static void |
enable(MetricsRegistry metricsRegistry,
java.io.File outputDir,
long period,
java.util.concurrent.TimeUnit unit)
Enables the CSV reporter for the given metrics registry, and causes it to write to files in
outputDir with the specified period. |
void |
processCounter(MetricName name,
Counter counter,
CsvReporter.Context context)
Process the given counter.
|
void |
processGauge(MetricName name,
Gauge<?> gauge,
CsvReporter.Context context)
Process the given gauge.
|
void |
processHistogram(MetricName name,
Histogram histogram,
CsvReporter.Context context)
Process the given histogram.
|
void |
processMeter(MetricName name,
Metered meter,
CsvReporter.Context context)
Process the given
Metered instance. |
void |
processTimer(MetricName name,
Timer timer,
CsvReporter.Context context)
Process the given timer.
|
void |
run()
The method called when a a poll is scheduled to occur.
|
void |
shutdown()
Stops the reporter and closes any internal resources.
|
void |
start(long period,
java.util.concurrent.TimeUnit unit)
Starts the reporter polling at the given period.
|
shutdown
getMetricsRegistry
public CsvReporter(MetricsRegistry metricsRegistry, java.io.File outputDir)
CsvReporter
which will write all metrics from the given
MetricsRegistry
to CSV files in the given output directory.outputDir
- the directory to which files will be writtenmetricsRegistry
- the MetricsRegistry
containing the metrics this reporter
will reportpublic CsvReporter(MetricsRegistry metricsRegistry, MetricPredicate predicate, java.io.File outputDir)
CsvReporter
which will write metrics from the given
MetricsRegistry
which match the given MetricPredicate
to CSV files in the
given output directory.metricsRegistry
- the MetricsRegistry
containing the metrics this reporter
will reportpredicate
- the MetricPredicate
which metrics are required to match
before being written to filesoutputDir
- the directory to which files will be writtenpublic CsvReporter(MetricsRegistry metricsRegistry, MetricPredicate predicate, java.io.File outputDir, Clock clock)
CsvReporter
which will write metrics from the given
MetricsRegistry
which match the given MetricPredicate
to CSV files in the
given output directory.metricsRegistry
- the MetricsRegistry
containing the metrics this reporter
will reportpredicate
- the MetricPredicate
which metrics are required to match
before being written to filesoutputDir
- the directory to which files will be writtenclock
- the clock used to measure timepublic static void enable(java.io.File outputDir, long period, java.util.concurrent.TimeUnit unit)
outputDir
with the specified period.outputDir
- the directory in which .csv
files will be createdperiod
- the period between successive outputsunit
- the time unit of period
public static void enable(MetricsRegistry metricsRegistry, java.io.File outputDir, long period, java.util.concurrent.TimeUnit unit)
outputDir
with the specified period.metricsRegistry
- the metrics registryoutputDir
- the directory in which .csv
files will be createdperiod
- the period between successive outputsunit
- the time unit of period
protected java.io.PrintStream createStreamForMetric(MetricName metricName) throws java.io.IOException
PrintStream
for the given MetricName
which outputs data
to a metric-specific .csv
file in the output directory.metricName
- the name of the metricPrintStream
specific to metricName
java.io.IOException
- if there is an error opening the streampublic void run()
AbstractPollingReporter
run
in interface java.lang.Runnable
run
in class AbstractPollingReporter
public void processMeter(MetricName name, Metered meter, CsvReporter.Context context) throws java.io.IOException
MetricProcessor
Metered
instance.processMeter
in interface MetricProcessor<CsvReporter.Context>
name
- the name of the metermeter
- the metercontext
- the context of the meterjava.io.IOException
public void processCounter(MetricName name, Counter counter, CsvReporter.Context context) throws java.io.IOException
MetricProcessor
processCounter
in interface MetricProcessor<CsvReporter.Context>
name
- the name of the countercounter
- the countercontext
- the context of the meterjava.io.IOException
public void processHistogram(MetricName name, Histogram histogram, CsvReporter.Context context) throws java.io.IOException
MetricProcessor
processHistogram
in interface MetricProcessor<CsvReporter.Context>
name
- the name of the histogramhistogram
- the histogramcontext
- the context of the meterjava.io.IOException
public void processTimer(MetricName name, Timer timer, CsvReporter.Context context) throws java.io.IOException
MetricProcessor
processTimer
in interface MetricProcessor<CsvReporter.Context>
name
- the name of the timertimer
- the timercontext
- the context of the meterjava.io.IOException
public void processGauge(MetricName name, Gauge<?> gauge, CsvReporter.Context context) throws java.io.IOException
MetricProcessor
processGauge
in interface MetricProcessor<CsvReporter.Context>
name
- the name of the gaugegauge
- the gaugecontext
- the context of the meterjava.io.IOException
public void start(long period, java.util.concurrent.TimeUnit unit)
AbstractPollingReporter
start
in class AbstractPollingReporter
period
- the amount of time between pollsunit
- the unit for period
public void shutdown()
AbstractReporter
shutdown
in class AbstractPollingReporter