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,
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,
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,
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 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(File outputDir,
long period,
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,
File outputDir,
long period,
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,
TimeUnit unit)
Starts the reporter polling at the given period.
|
shutdowngetMetricsRegistrypublic CsvReporter(MetricsRegistry metricsRegistry, 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, 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, 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(File outputDir, long period, 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 periodpublic static void enable(MetricsRegistry metricsRegistry, File outputDir, long period, 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 periodprotected PrintStream createStreamForMetric(MetricName metricName) throws 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 metricNameIOException - if there is an error opening the streampublic void run()
AbstractPollingReporterrun in interface Runnablerun in class AbstractPollingReporterpublic void processMeter(MetricName name, Metered meter, CsvReporter.Context context) throws IOException
MetricProcessorMetered instance.processMeter in interface MetricProcessor<CsvReporter.Context>name - the name of the metermeter - the metercontext - the context of the meterIOExceptionpublic void processCounter(MetricName name, Counter counter, CsvReporter.Context context) throws IOException
MetricProcessorprocessCounter in interface MetricProcessor<CsvReporter.Context>name - the name of the countercounter - the countercontext - the context of the meterIOExceptionpublic void processHistogram(MetricName name, Histogram histogram, CsvReporter.Context context) throws IOException
MetricProcessorprocessHistogram in interface MetricProcessor<CsvReporter.Context>name - the name of the histogramhistogram - the histogramcontext - the context of the meterIOExceptionpublic void processTimer(MetricName name, Timer timer, CsvReporter.Context context) throws IOException
MetricProcessorprocessTimer in interface MetricProcessor<CsvReporter.Context>name - the name of the timertimer - the timercontext - the context of the meterIOExceptionpublic void processGauge(MetricName name, Gauge<?> gauge, CsvReporter.Context context) throws IOException
MetricProcessorprocessGauge in interface MetricProcessor<CsvReporter.Context>name - the name of the gaugegauge - the gaugecontext - the context of the meterIOExceptionpublic void start(long period,
TimeUnit unit)
AbstractPollingReporterstart in class AbstractPollingReporterperiod - the amount of time between pollsunit - the unit for periodpublic void shutdown()
AbstractReportershutdown in class AbstractPollingReporterCopyright © 2012. All Rights Reserved.