Class RedisMetricRepository

    • Constructor Summary

      Constructors 
      ConstructorDescription
      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.
    • Constructor Detail

      • 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.
        Parameters:
        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.
        Parameters:
        redisConnectionFactory - the redis connection factory
        prefix - 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, especially findAll() and count(), will only be accurate if the key is unique to the prefix of this repository.
        Parameters:
        redisConnectionFactory - the redis connection factory
        prefix - the prefix to set for all metrics keys
        key - the key to set
    • Method Detail

      • findOne

        public Metric<?> findOne​(String metricName)
        Description copied from interface: MetricReader
        Find an instance of the metric with the given name (usually the latest recorded value).
        Specified by:
        findOne in interface MetricReader
        Parameters:
        metricName - the name of the metric to find
        Returns:
        a metric value or null if there are none with that name
      • count

        public long count()
        Description copied from interface: MetricReader
        The number of metrics known to this reader.
        Specified by:
        count in interface MetricReader
        Returns:
        the number of metrics
      • increment

        public void increment​(Delta<?> delta)
        Description copied from interface: 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.
        Specified by:
        increment in interface CounterWriter
        Parameters:
        delta - the amount to increment by
      • set

        public void set​(Metric<?> value)
        Description copied from interface: GaugeWriter
        Set the value of a metric.
        Specified by:
        set in interface GaugeWriter
        Parameters:
        value - the value
      • reset

        public void reset​(String metricName)
        Description copied from interface: 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).
        Specified by:
        reset in interface CounterWriter
        Parameters:
        metricName - the name to reset