public class MetricCopyExporter extends AbstractMetricExporter
Exporter
that "exports" by copying metric data from a source
MetricReader
to a destination MetricWriter
. Actually the output writer
can be a GaugeWriter
, in which case all metrics are simply output as their
current value. If the output writer is also a CounterWriter
then metrics whose
names begin with "counter." are special: instead of writing them out as simple gauges
the writer will increment the counter value. This involves the exporter storing the
previous value of the counter so the delta can be computed. For best results with the
counters, do not use the exporter concurrently in multiple threads (normally it will
only be used periodically and sequentially, even if it is in a background thread, and
this is fine).Constructor and Description |
---|
MetricCopyExporter(MetricReader reader,
GaugeWriter writer)
Create a new
MetricCopyExporter instance. |
MetricCopyExporter(MetricReader reader,
GaugeWriter writer,
String prefix)
Create a new
MetricCopyExporter instance. |
Modifier and Type | Method and Description |
---|---|
void |
flush() |
protected Iterable<Metric<?>> |
next(String group)
Get the next group of metrics to write.
|
void |
setExcludes(String... excludes)
Set the exclude patterns used to filter metrics.
|
void |
setIncludes(String... includes)
Set the include patterns used to filter metrics.
|
protected void |
write(String group,
Collection<Metric<?>> values)
Write the values associated with a group.
|
close, export, groups, setEarliestTimestamp, setIgnoreTimestamps, setSendLatest
public MetricCopyExporter(MetricReader reader, GaugeWriter writer)
MetricCopyExporter
instance.reader
- the metric readerwriter
- the metric writerpublic MetricCopyExporter(MetricReader reader, GaugeWriter writer, String prefix)
MetricCopyExporter
instance.reader
- the metric readerwriter
- the metric writerprefix
- the name prefixpublic void setIncludes(String... includes)
includes
- the include patternspublic void setExcludes(String... excludes)
excludes
- the exclude patternsprotected Iterable<Metric<?>> next(String group)
AbstractMetricExporter
next
in class AbstractMetricExporter
group
- the group name to writeprotected void write(String group, Collection<Metric<?>> values)
AbstractMetricExporter
write
in class AbstractMetricExporter
group
- the group to writevalues
- the values to writepublic void flush()
flush
in interface Flushable
flush
in class AbstractMetricExporter
Copyright © 2017 Pivotal Software, Inc.. All rights reserved.