public class InMemoryMetricRepository extends Object implements MetricRepository, MultiMetricRepository, PrefixMetricReader
MetricRepository
and MultiMetricRepository
implementation that stores
metrics in memory.Constructor and Description |
---|
InMemoryMetricRepository() |
Modifier and Type | Method and Description |
---|---|
long |
count()
The number of metrics known to this reader.
|
long |
countGroups() |
Iterable<Metric<?>> |
findAll()
Find all the metrics known to this reader.
|
Iterable<Metric<?>> |
findAll(String metricNamePrefix)
Find all metrics whose name starts with the given prefix.
|
Metric<?> |
findOne(String metricName)
Find an instance of the metric with the given name (usually the latest recorded
value).
|
Iterable<String> |
groups()
The names of all the groups known to this repository
|
void |
increment(Delta<?> delta)
Increment the value of a metric (or decrement if the delta is negative).
|
void |
increment(String group,
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 |
set(String group,
Collection<Metric<?>> values)
Save some metric values and associate them with a group name.
|
void |
setValues(ConcurrentNavigableMap<String,Metric<?>> values) |
public void setValues(ConcurrentNavigableMap<String,Metric<?>> values)
public void increment(Delta<?> delta)
MetricWriter
increment
in interface MetricWriter
delta
- the amount to increment bypublic void set(Metric<?> value)
MetricWriter
set
in interface MetricWriter
value
- the valuepublic void set(String group, Collection<Metric<?>> values)
PrefixMetricWriter
set
in interface PrefixMetricWriter
group
- the name of the groupvalues
- the metric values to savepublic void increment(String group, Delta<?> delta)
PrefixMetricWriter
group + "." + delta.name
.increment
in interface PrefixMetricWriter
group
- the name of the groupdelta
- the amount to increment bypublic Iterable<String> groups()
MultiMetricRepository
groups
in interface MultiMetricRepository
public long count()
MetricReader
count
in interface MetricReader
public long countGroups()
countGroups
in interface MultiMetricRepository
public void reset(String metricName)
MetricWriter
reset
in interface MetricWriter
reset
in interface PrefixMetricWriter
metricName
- the name to resetpublic Metric<?> findOne(String metricName)
MetricReader
findOne
in interface MetricReader
metricName
- the name of the metric to findpublic Iterable<Metric<?>> findAll()
MetricReader
findAll
in interface MetricReader
public Iterable<Metric<?>> findAll(String metricNamePrefix)
PrefixMetricReader
findAll
in interface PrefixMetricReader
metricNamePrefix
- the prefix for metric namesCopyright © 2015 Pivotal Software, Inc.. All rights reserved.