类 RedisMetricRepository
- java.lang.Object
- org.springframework.boot.actuate.metrics.repository.redis.RedisMetricRepository
- 所有已实现的接口:
MetricReader
,MetricRepository
,CounterWriter
,GaugeWriter
,MetricWriter
public class RedisMetricRepository extends Object implements MetricRepository
AMetricRepository
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).
构造器概要
构造器 构造器 说明 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.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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.
构造器详细资料
RedisMetricRepository
public RedisMetricRepository(org.springframework.data.redis.connection.RedisConnectionFactory redisConnectionFactory)
Create a RedisMetricRepository with a default prefix to apply to all metric names. If multiple repositories share a redis instance they will feed into the same global metrics.- 参数:
redisConnectionFactory
- the redis connection factory
RedisMetricRepository
public 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). Recommended constructor for general purpose use.- 参数:
redisConnectionFactory
- the redis connection factoryprefix
- the prefix to set for all metrics keys
RedisMetricRepository
public 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. The redis store will hold a zset under the key just so the metric names can be enumerated. Read operations, especiallyfindAll()
andcount()
, 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 set
方法详细资料
findOne
public Metric<?> findOne(String metricName)
从接口复制的说明:MetricReader
Find an instance of the metric with the given name (usually the latest recorded value).- 指定者:
findOne
在接口中MetricReader
- 参数:
metricName
- the name of the metric to find- 返回:
- a metric value or null if there are none with that name
findAll
public Iterable<Metric<?>> findAll()
从接口复制的说明:MetricReader
Find all the metrics known to this reader.- 指定者:
findAll
在接口中MetricReader
- 返回:
- all instances of metrics known to this reader
count
public long count()
从接口复制的说明:MetricReader
The number of metrics known to this reader.- 指定者:
count
在接口中MetricReader
- 返回:
- the number of metrics
increment
public void increment(Delta<?> delta)
从接口复制的说明: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.- 指定者:
increment
在接口中CounterWriter
- 参数:
delta
- the amount to increment by
set
public void set(Metric<?> value)
从接口复制的说明:GaugeWriter
Set the value of a metric.- 指定者:
set
在接口中GaugeWriter
- 参数:
value
- the value
reset
public void reset(String metricName)
从接口复制的说明: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).- 指定者:
reset
在接口中CounterWriter
- 参数:
metricName
- the name to reset