Class MicrometerHolder


  • public final class MicrometerHolder
    extends java.lang.Object
    A wrapper for micrometer timers when available on the class path.
    Since:
    2.5
    Author:
    Gary Russell
    • Constructor Summary

      Constructors 
      Constructor Description
      MicrometerHolder​(org.springframework.context.ApplicationContext context, java.lang.String name, java.lang.String timerName, java.lang.String timerDesc, java.util.function.Function<java.lang.Object,​java.util.Map<java.lang.String,​java.lang.String>> tagsProvider)
      Create an instance with the provided properties.
      MicrometerHolder​(org.springframework.context.ApplicationContext context, java.lang.String name, java.lang.String timerName, java.lang.String timerDesc, java.util.Map<java.lang.String,​java.lang.String> tags)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void destroy()
      Remove the timers.
      void failure​(java.lang.Object sample, java.lang.String exception)
      Record failure.
      void failure​(java.lang.Object sample, java.lang.String exception, java.lang.Object record)
      Record failure.
      java.lang.Object start()
      Start the timer.
      void success​(java.lang.Object sample)
      Record success.
      void success​(java.lang.Object sample, java.lang.Object record)
      Record success.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MicrometerHolder

        @Deprecated
        public MicrometerHolder​(@Nullable
                                org.springframework.context.ApplicationContext context,
                                java.lang.String name,
                                java.lang.String timerName,
                                java.lang.String timerDesc,
                                java.util.Map<java.lang.String,​java.lang.String> tags)
        Create an instance with the provided properties.
        Parameters:
        context - the application context from which to obtain the meter registry.
        name - the value of the 'name' tag.
        timerName - the timer name.
        timerDesc - the timer description.
        tags - additional tags.
      • MicrometerHolder

        public MicrometerHolder​(@Nullable
                                org.springframework.context.ApplicationContext context,
                                java.lang.String name,
                                java.lang.String timerName,
                                java.lang.String timerDesc,
                                java.util.function.Function<java.lang.Object,​java.util.Map<java.lang.String,​java.lang.String>> tagsProvider)
        Create an instance with the provided properties.
        Parameters:
        context - the application context from which to obtain the meter registry.
        name - the value of the 'name' tag.
        timerName - the timer name.
        timerDesc - the timer description.
        tagsProvider - the tags provider.
        Since:
        2.9.7
    • Method Detail

      • start

        public java.lang.Object start()
        Start the timer.
        Returns:
        the sample.
      • success

        public void success​(java.lang.Object sample)
        Record success.
        Parameters:
        sample - the sample.
        See Also:
        start()
      • failure

        public void failure​(java.lang.Object sample,
                            java.lang.String exception)
        Record failure.
        Parameters:
        sample - the sample.
        exception - the exception name.
        See Also:
        start()
      • success

        public void success​(java.lang.Object sample,
                            java.lang.Object record)
        Record success.
        Parameters:
        sample - the sample.
        record - the consumer record.
        See Also:
        start()
      • failure

        public void failure​(java.lang.Object sample,
                            java.lang.String exception,
                            java.lang.Object record)
        Record failure.
        Parameters:
        sample - the sample.
        exception - the exception name.
        record - the consumer record.
        See Also:
        start()
      • destroy

        public void destroy()
        Remove the timers.