public class RedisMetricRepository extends Object implements MetricRepository
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)
Create a RedisMetricRepository with a default prefix to apply to all metric names.
|
RedisMetricRepository(org.springframework.data.redis.connection.RedisConnectionFactory redisConnectionFactory,
String prefix)
Create a RedisMetricRepository with a prefix to apply to all metric names (ideally
unique to this repository or to a logical repository contributed to by multiple
instances, where they all see the same values).
|
RedisMetricRepository(org.springframework.data.redis.connection.RedisConnectionFactory redisConnectionFactory,
String prefix,
String key)
Allows user to set the prefix and key to use to store the index of other keys.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
public RedisMetricRepository(org.springframework.data.redis.connection.RedisConnectionFactory redisConnectionFactory)
redisConnectionFactory - the redis connection factorypublic RedisMetricRepository(org.springframework.data.redis.connection.RedisConnectionFactory redisConnectionFactory,
String prefix)
redisConnectionFactory - the redis connection factoryprefix - the prefix to set for all metrics keyspublic RedisMetricRepository(org.springframework.data.redis.connection.RedisConnectionFactory redisConnectionFactory,
String prefix,
String key)
findAll() and count(),
will only be accurate if the key is unique to the prefix of this repository.redisConnectionFactory - the redis connection factoryprefix - the prefix to set for all metrics keyskey - 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)
CounterWriterincrement in interface CounterWriterdelta - the amount to increment bypublic void set(Metric<?> value)
GaugeWriterset in interface GaugeWritervalue - the valuepublic void reset(String metricName)
CounterWriterreset in interface CounterWritermetricName - the name to resetCopyright © 2015 Pivotal Software, Inc.. All rights reserved.