Interface AutoTimer

All Known Implementing Classes:
PropertiesAutoTimer
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:
4.0.0
Author:
Tadaya Tsuyukubo, Stephane Nicoll, Phillip Webb
  • 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 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 Timer.Builder builder(Supplier<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(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(@Nullable AutoTimer autoTimer, String metricName, Set<Timed> annotations, Consumer<Timer.Builder> action)