Interface AutoTimer

All Known Implementing Classes:
AutoTimeProperties
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface AutoTimer
Strategy that can be used to apply Timers automatically instead of using @Timed.
Since:
2.2.0
Author:
Tadaya Tsuyukubo, Stephane Nicoll, Phillip Webb
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final AutoTimer
    An AutoTimer implementation that is disabled and will not record metrics.
    static final AutoTimer
    An AutoTimer implementation that is enabled but applies no additional customizations.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    apply(io.micrometer.core.instrument.Timer.Builder builder)
    Called to apply any auto-timer settings to the given Timer.Builder.
    static void
    apply(AutoTimer autoTimer, String metricName, Set<io.micrometer.core.annotation.Timed> annotations, Consumer<io.micrometer.core.instrument.Timer.Builder> action)
     
    default io.micrometer.core.instrument.Timer.Builder
    Factory method to create a new Timer.Builder with auto-timer settings applied.
    default io.micrometer.core.instrument.Timer.Builder
    builder(Supplier<io.micrometer.core.instrument.Timer.Builder> supplier)
    Factory method to create a new Timer.Builder with auto-timer settings applied.
    default boolean
    Return if the auto-timer is enabled and metrics should be recorded.
  • Field Details

    • ENABLED

      static final AutoTimer ENABLED
      An AutoTimer implementation that is enabled but applies no additional customizations.
    • DISABLED

      static final AutoTimer DISABLED
      An AutoTimer implementation that is disabled and will not record metrics.
  • Method Details

    • isEnabled

      default boolean isEnabled()
      Return if the auto-timer is enabled and metrics should be recorded.
      Returns:
      if the auto-timer is enabled
    • builder

      default io.micrometer.core.instrument.Timer.Builder builder(String name)
      Factory method to create a new Timer.Builder with auto-timer settings applied.
      Parameters:
      name - the name of the timer
      Returns:
      a new builder instance with auto-settings applied
    • builder

      default io.micrometer.core.instrument.Timer.Builder builder(Supplier<io.micrometer.core.instrument.Timer.Builder> supplier)
      Factory method to create a new Timer.Builder with auto-timer settings applied.
      Parameters:
      supplier - the builder supplier
      Returns:
      a new builder instance with auto-settings applied
    • apply

      void apply(io.micrometer.core.instrument.Timer.Builder builder)
      Called to apply any auto-timer settings to the given Timer.Builder.
      Parameters:
      builder - the builder to apply settings to
    • apply

      static void apply(AutoTimer autoTimer, String metricName, Set<io.micrometer.core.annotation.Timed> annotations, Consumer<io.micrometer.core.instrument.Timer.Builder> action)