public class RedisMetricRepository extends Object implements MetricRepository, org.springframework.beans.factory.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(org.springframework.data.redis.connection.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(org.springframework.data.redis.connection.RedisConnectionFactory redisConnectionFactory)
public void afterPropertiesSet()
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanpublic 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)
MetricReaderfindOne in interface MetricReadermetricName - the name of the metric to findpublic Iterable<Metric<?>> findAll()
MetricReaderfindAll in interface MetricReaderpublic long count()
MetricReadercount in interface MetricReaderpublic void increment(Delta<?> delta)
MetricWriterincrement in interface MetricWriterdelta - the amount to increment bypublic void set(Metric<?> value)
MetricWriterset in interface MetricWriterpublic void reset(String metricName)
MetricWriterreset in interface MetricWritermetricName - the name to resetCopyright © 2014 Pivotal Software, Inc.. All rights reserved.