Class AbstractMetricExporter
- java.lang.Object
- org.springframework.boot.actuate.metrics.export.AbstractMetricExporter
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
,Exporter
- Direct Known Subclasses:
MetricCopyExporter
,PrefixMetricGroupExporter
,RichGaugeExporter
public abstract class AbstractMetricExporter extends Object implements Exporter, Closeable, Flushable
Base class for metric exporters that have common features, principally a prefix for exported metrics and filtering by timestamp (so only new values are included in the export).- Since:
- 1.3.0
Constructor Summary
Constructors Constructor Description AbstractMetricExporter(String prefix)
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
void
export()
Export metric data.void
flush()
protected Iterable<String>
groups()
Generate a group of metrics to iterate over in the form of a set of Strings (e.g.protected abstract Iterable<Metric<?>>
next(String group)
Get the next group of metrics to write.void
setEarliestTimestamp(Date earliestTimestamp)
The earliest time for which data will be exported.void
setIgnoreTimestamps(boolean ignoreTimestamps)
Ignore timestamps (export all metrics).void
setSendLatest(boolean sendLatest)
Send only the data that changed since the last export.protected abstract void
write(String group, Collection<Metric<?>> values)
Write the values associated with a group.
Constructor Detail
AbstractMetricExporter
public AbstractMetricExporter(String prefix)
Method Detail
setEarliestTimestamp
public void setEarliestTimestamp(Date earliestTimestamp)
The earliest time for which data will be exported.- Parameters:
earliestTimestamp
- the timestamp to set
setIgnoreTimestamps
public void setIgnoreTimestamps(boolean ignoreTimestamps)
Ignore timestamps (export all metrics).- Parameters:
ignoreTimestamps
- the flag to set
setSendLatest
public void setSendLatest(boolean sendLatest)
Send only the data that changed since the last export.- Parameters:
sendLatest
- the flag to set
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
groups
protected Iterable<String> groups()
Generate a group of metrics to iterate over in the form of a set of Strings (e.g. prefixes). If the metrics to be exported partition into groups identified by a String, subclasses should override this method. Otherwise the default should be fine (iteration over all metrics).- Returns:
- groups of metrics to iterate over (default singleton empty string)
write
protected abstract void write(String group, Collection<Metric<?>> values)
Write the values associated with a group.- Parameters:
group
- the group to writevalues
- the values to write