public class RedisMetricRepository extends Object implements MetricRepository, InitializingBean
MetricRepository
implementation for a redis backend. Metric values are stored
as zset values plus a regular hash value for the timestamp, both against a key composed
of the metric name prefixed with a constant (default "spring.metrics."). If you have
multiple metrics repositories all point at the same instance of Redis, it may be useful
to change the prefix to be unique (but not if you want them to contribute to the same
metrics).Constructor and Description |
---|
RedisMetricRepository(RedisConnectionFactory redisConnectionFactory) |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
long |
count()
The number of metrics known to this reader.
|
Iterable<Metric<?>> |
findAll()
Find all the metrics known to this reader.
|
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 |
setKey(String key)
The redis key to use to store the index of other keys.
|
void |
setPrefix(String prefix)
The prefix for all metrics keys.
|
public RedisMetricRepository(RedisConnectionFactory redisConnectionFactory)
public void afterPropertiesSet()
afterPropertiesSet
in interface InitializingBean
public void setPrefix(String prefix)
prefix
- the prefix to set for all metrics keyspublic void setKey(String key)
findAll()
and count()
, will be much more efficient if the key is
unique to the prefix
of this repository.key
- the key to setpublic 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 long count()
MetricReader
count
in interface MetricReader
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
public void reset(String metricName)
MetricWriter
reset
in interface MetricWriter
metricName
- the name to resetCopyright © 2014 Pivotal Software, Inc.. All rights reserved.