Class InMemoryMetricRepository
- java.lang.Object
- org.springframework.boot.actuate.metrics.repository.InMemoryMetricRepository
- All Implemented Interfaces:
MetricReader
,MetricRepository
,CounterWriter
,GaugeWriter
,MetricWriter
public class InMemoryMetricRepository extends Object implements MetricRepository
MetricRepository
implementation that stores metrics in memory.
Constructor Summary
Constructors Constructor Description InMemoryMetricRepository()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
count()
The number of metrics known to this reader.Iterable<Metric<?>>
findAll()
Find all the metrics known to this reader.Iterable<Metric<?>>
findAllWithPrefix(String prefix)
Metric<?>
findOne(String metricName)
Find an instance of the metric with the given name (usually the latest recorded value).void
increment(Delta<?> delta)
Increment the value of a metric (or decrement if the delta is negative).void
reset(String metricName)
Reset the value of a metric, usually to zero value.void
set(Metric<?> value)
Set the value of a metric.void
setValues(ConcurrentNavigableMap<String,Metric<?>> values)
Constructor Detail
InMemoryMetricRepository
public InMemoryMetricRepository()
Method Detail
setValues
public void setValues(ConcurrentNavigableMap<String,Metric<?>> values)
increment
public void increment(Delta<?> delta)
Description copied from interface:CounterWriter
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.- Specified by:
increment
in interfaceCounterWriter
- Parameters:
delta
- the amount to increment by
set
public void set(Metric<?> value)
Description copied from interface:GaugeWriter
Set the value of a metric.- Specified by:
set
in interfaceGaugeWriter
- Parameters:
value
- the value
count
public long count()
Description copied from interface:MetricReader
The number of metrics known to this reader.- Specified by:
count
in interfaceMetricReader
- Returns:
- the number of metrics
reset
public void reset(String metricName)
Description copied from interface:CounterWriter
Reset the value of a metric, usually to zero value. Implementations can discard the old values if desired, but may choose not to. This operation is optional (some implementations may not be able to fulfill the contract, in which case they should simply do nothing).- Specified by:
reset
in interfaceCounterWriter
- Parameters:
metricName
- the name to reset
findOne
public Metric<?> findOne(String metricName)
Description copied from interface:MetricReader
Find an instance of the metric with the given name (usually the latest recorded value).- Specified by:
findOne
in interfaceMetricReader
- Parameters:
metricName
- the name of the metric to find- Returns:
- a metric value or null if there are none with that name
findAll
public Iterable<Metric<?>> findAll()
Description copied from interface:MetricReader
Find all the metrics known to this reader.- Specified by:
findAll
in interfaceMetricReader
- Returns:
- all instances of metrics known to this reader
findAllWithPrefix
public Iterable<Metric<?>> findAllWithPrefix(String prefix)