parent
d23dab3bd0
commit
a2f70c6f4f
|
|
@ -26,6 +26,9 @@ import org.springframework.boot.actuate.metrics.repository.MultiMetricRepository
|
||||||
import org.springframework.boot.actuate.metrics.writer.MetricWriter;
|
import org.springframework.boot.actuate.metrics.writer.MetricWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A convenient exporter for a group of metrics from a {@link PrefixMetricReader}. Exports
|
||||||
|
* all metrics whose name starts with a prefix (or all metrics if the prefix is empty).
|
||||||
|
*
|
||||||
* @author Dave Syer
|
* @author Dave Syer
|
||||||
*/
|
*/
|
||||||
public class PrefixMetricGroupExporter extends AbstractMetricExporter {
|
public class PrefixMetricGroupExporter extends AbstractMetricExporter {
|
||||||
|
|
@ -36,10 +39,25 @@ public class PrefixMetricGroupExporter extends AbstractMetricExporter {
|
||||||
|
|
||||||
private Set<String> groups = new HashSet<String>();
|
private Set<String> groups = new HashSet<String>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new exporter for metrics to a writer based on an empty prefix for the
|
||||||
|
* metric names.
|
||||||
|
*
|
||||||
|
* @param reader a reader as the source of metrics
|
||||||
|
* @param writer the writer to send the metrics to
|
||||||
|
*/
|
||||||
public PrefixMetricGroupExporter(PrefixMetricReader reader, MetricWriter writer) {
|
public PrefixMetricGroupExporter(PrefixMetricReader reader, MetricWriter writer) {
|
||||||
this(reader, writer, "");
|
this(reader, writer, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new exporter for metrics to a writer based on a prefix for the metric
|
||||||
|
* names.
|
||||||
|
*
|
||||||
|
* @param reader a reader as the source of metrics
|
||||||
|
* @param writer the writer to send the metrics to
|
||||||
|
* @param prefix the prefix for metrics to export
|
||||||
|
*/
|
||||||
public PrefixMetricGroupExporter(PrefixMetricReader reader, MetricWriter writer,
|
public PrefixMetricGroupExporter(PrefixMetricReader reader, MetricWriter writer,
|
||||||
String prefix) {
|
String prefix) {
|
||||||
super(prefix);
|
super(prefix);
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,27 @@ import org.springframework.boot.actuate.metrics.Metric;
|
||||||
*/
|
*/
|
||||||
public interface MetricReader {
|
public interface MetricReader {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find an instance of the metric with the given name (usually the latest recorded
|
||||||
|
* value).
|
||||||
|
*
|
||||||
|
* @param metricName the name of the metric to find
|
||||||
|
* @return a metric value or null if there are none with that name
|
||||||
|
*/
|
||||||
Metric<?> findOne(String metricName);
|
Metric<?> findOne(String metricName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find all the metrics known to this reader.
|
||||||
|
*
|
||||||
|
* @return all instances of metrics known to this reader
|
||||||
|
*/
|
||||||
Iterable<Metric<?>> findAll();
|
Iterable<Metric<?>> findAll();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of metrics known to this reader.
|
||||||
|
*
|
||||||
|
* @return the number of metrics
|
||||||
|
*/
|
||||||
long count();
|
long count();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,12 @@ import org.springframework.boot.actuate.metrics.Metric;
|
||||||
*/
|
*/
|
||||||
public interface PrefixMetricReader {
|
public interface PrefixMetricReader {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find all metrics whose name starts with the given prefix.
|
||||||
|
*
|
||||||
|
* @param prefix the prefix for metric names
|
||||||
|
* @return all metrics with names starting with the prefix
|
||||||
|
*/
|
||||||
Iterable<Metric<?>> findAll(String prefix);
|
Iterable<Metric<?>> findAll(String prefix);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,12 +29,32 @@ import org.springframework.boot.actuate.metrics.reader.PrefixMetricReader;
|
||||||
*/
|
*/
|
||||||
public interface MultiMetricRepository extends PrefixMetricReader {
|
public interface MultiMetricRepository extends PrefixMetricReader {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save some metric values and associate them with a group name.
|
||||||
|
*
|
||||||
|
* @param group the name of the group
|
||||||
|
* @param values the metric values to save
|
||||||
|
*/
|
||||||
void save(String group, Collection<Metric<?>> values);
|
void save(String group, Collection<Metric<?>> values);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rest the values of all metrics in the group. Implementations may choose to discard
|
||||||
|
* the old values.
|
||||||
|
*
|
||||||
|
* @param group reset the whole group
|
||||||
|
*/
|
||||||
void reset(String group);
|
void reset(String group);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The names of all the groups known to this repository
|
||||||
|
*
|
||||||
|
* @return all available group names
|
||||||
|
*/
|
||||||
Iterable<String> groups();
|
Iterable<String> groups();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the number of groups available
|
||||||
|
*/
|
||||||
long count();
|
long count();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,24 @@ package org.springframework.boot.actuate.metrics.rich;
|
||||||
*/
|
*/
|
||||||
public interface RichGaugeReader {
|
public interface RichGaugeReader {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find a single instance of a rich gauge by name.
|
||||||
|
*
|
||||||
|
* @param name the name of the gauge
|
||||||
|
* @return a rich gauge value
|
||||||
|
*/
|
||||||
RichGauge findOne(String name);
|
RichGauge findOne(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find all instances of rich gauge known to this reader.
|
||||||
|
*
|
||||||
|
* @return all instances known to this reader
|
||||||
|
*/
|
||||||
Iterable<RichGauge> findAll();
|
Iterable<RichGauge> findAll();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the number of gauge values available
|
||||||
|
*/
|
||||||
long count();
|
long count();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,27 @@ import org.springframework.boot.actuate.metrics.Metric;
|
||||||
*/
|
*/
|
||||||
public interface MetricWriter {
|
public interface MetricWriter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increment the value of a metric (or decrement if the delta is negative). The name
|
||||||
|
* of the delta is the name of the metric to increment.
|
||||||
|
*
|
||||||
|
* @param delta the amount to increment by
|
||||||
|
*/
|
||||||
void increment(Delta<?> delta);
|
void increment(Delta<?> delta);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the value of a metric.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
void set(Metric<?> value);
|
void set(Metric<?> value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the value of a metric, usually to zero value. Implementations can discard the
|
||||||
|
* old values if desired, but may choose not to.
|
||||||
|
*
|
||||||
|
* @param metricName the name to reset
|
||||||
|
*/
|
||||||
void reset(String metricName);
|
void reset(String metricName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue