Class MetricCopyExporter
- java.lang.Object
- org.springframework.boot.actuate.metrics.export.AbstractMetricExporter
- org.springframework.boot.actuate.metrics.export.MetricCopyExporter
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
,Exporter
public class MetricCopyExporter extends AbstractMetricExporter
Exporter
that "exports" by copying metric data from a sourceMetricReader
to a destinationMetricWriter
. Actually the output writer can be aGaugeWriter
, in which case all metrics are simply output as their current value. If the output writer is also aCounterWriter
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).- Since:
- 1.3.0
Constructor Summary
Constructors Constructor Description MetricCopyExporter(MetricReader reader, GaugeWriter writer)
Create a newMetricCopyExporter
instance.MetricCopyExporter(MetricReader reader, GaugeWriter writer, String prefix)
Create a newMetricCopyExporter
instance.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.Methods inherited from class org.springframework.boot.actuate.metrics.export.AbstractMetricExporter
close, export, groups, setEarliestTimestamp, setIgnoreTimestamps, setSendLatest
Constructor Detail
MetricCopyExporter
public MetricCopyExporter(MetricReader reader, GaugeWriter writer)
Create a newMetricCopyExporter
instance.- Parameters:
reader
- the metric readerwriter
- the metric writer
MetricCopyExporter
public MetricCopyExporter(MetricReader reader, GaugeWriter writer, String prefix)
Create a newMetricCopyExporter
instance.- Parameters:
reader
- the metric readerwriter
- the metric writerprefix
- the name prefix
Method Detail
setIncludes
public void setIncludes(String... includes)
Set the include patterns used to filter metrics.- Parameters:
includes
- the include patterns
setExcludes
public void setExcludes(String... excludes)
Set the exclude patterns used to filter metrics.- Parameters:
excludes
- the exclude patterns
next
protected Iterable<Metric<?>> next(String group)
Description copied from class:AbstractMetricExporter
Get the next group of metrics to write.- Specified by:
next
in classAbstractMetricExporter
- Parameters:
group
- the group name to write- Returns:
- some metrics to write
write
protected void write(String group, Collection<Metric<?>> values)
Description copied from class:AbstractMetricExporter
Write the values associated with a group.- Specified by:
write
in classAbstractMetricExporter
- Parameters:
group
- the group to writevalues
- the values to write
flush
public void flush()
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classAbstractMetricExporter