Class MetricsService


  • @Service
    public class MetricsService
    extends Object
    • Field Detail

      • counterTags

        protected Map<String,​Set<io.micrometer.core.instrument.Tag>> counterTags
      • timers

        protected Map<String,​io.micrometer.core.instrument.Timer> timers
    • Constructor Detail

      • MetricsService

        public MetricsService​(io.micrometer.core.instrument.MeterRegistry meterRegistry)
    • Method Detail

      • setGauge

        public void setGauge​(String name,
                             long value)
        Sets the value of a gauge
        Parameters:
        name - Name of the gauge, postfixed with .amount
        value - Value of the gauge
      • setGauge

        public void setGauge​(String name,
                             String tag,
                             long value)
        Sets the value of a gauge
        Parameters:
        name - Name of the gauge, postfixed with .amount
        tag - Name of the tag (key is type)
        value - Value of the gauge
      • setGauge

        public void setGauge​(String name,
                             String tagKey,
                             String tagValue,
                             long value)
        Sets the value of a gauge
        Parameters:
        name - Name of the gauge, postfixed with .amount
        tagKey - Name of the tag
        tagValue - Value of the tag
        value - Value of the gauge
      • increaseCounter

        public void increaseCounter​(String name,
                                    String tag)
        Increases the gauge counter by one
        Parameters:
        name - Name of the gauge, postfixed with .amount
        tag - Name of the tag
      • increaseCounter

        public void increaseCounter​(String name,
                                    String tag,
                                    long increment)
        Increases the gauge counter with a custom increment
        Parameters:
        name - Name of the gauge, postfixed with .amount
        tag - Name of the tag
        increment - Increment value
      • increaseCounterWithDuration

        public void increaseCounterWithDuration​(String name,
                                                String tag,
                                                Long durationMillis)
        Increases the gauge counter and logs its accompanied duration
        Parameters:
        name - Name of the gauge, postfixed with .amount and name of the timer, postfixed with .duration
        tag - Name of the tag
        durationMillis - Duration in milliseconds
      • increaseCounterWithDurationAndPercentiles

        public void increaseCounterWithDurationAndPercentiles​(String name,
                                                              String tag,
                                                              Long durationMillis)
        Increases the gauge counter and logs its accompanied duration including percentiles (0.5 and 0.95) and histogram
        Parameters:
        name - Name of the gauge, postfixed with .amount and name of the timer, postfixed with .duration
        tag - Name of the tag (must not be null)
        durationMillis - Duration in milliseconds
      • getCounterTags

        protected Map<String,​Set<io.micrometer.core.instrument.Tag>> getCounterTags()
      • getTimers

        protected Map<String,​io.micrometer.core.instrument.Timer> getTimers()