Interface Timer

All Known Implementing Classes:
TimerImpl

public interface Timer
Collects metrics of the decorated operation.
  • Method Details

    • of

      static Timer of(String name, io.micrometer.core.instrument.MeterRegistry registry)
      Creates a Timer with a default Timer configuration.
      Parameters:
      name - the name of the Timer
      registry - the registry to bind Timer to
      Returns:
      a Timer with a custom Timer configuration.
    • of

      static Timer of(String name, io.micrometer.core.instrument.MeterRegistry registry, TimerConfig timerConfig)
      Creates a Timer with a custom Timer configuration.
      Parameters:
      name - the name of the Timer
      registry - the registry to bind Timer to
      timerConfig - a custom Timer configuration
      Returns:
      a Timer with a custom Timer configuration.
    • of

      static Timer of(String name, io.micrometer.core.instrument.MeterRegistry registry, TimerConfig timerConfig, Map<String,String> tags)
      Creates a Timer with a custom Timer configuration.
      Parameters:
      name - the name of the Timer
      registry - the registry to bind Timer to
      timerConfig - a custom Timer configuration
      tags - tags to assign to the Timer
      Returns:
      a Timer with a custom Timer configuration.
    • decorateCompletionStage

      static <T> Supplier<CompletionStage<T>> decorateCompletionStage(Timer timer, Supplier<CompletionStage<T>> supplier)
      Decorates CompletionStageSupplier with Timer
      Type Parameters:
      T - type of completion stage result
      Parameters:
      timer - the timer
      supplier - completion stage supplier
      Returns:
      decorated supplier
    • decorateCheckedSupplier

      static <T> io.github.resilience4j.core.functions.CheckedSupplier<T> decorateCheckedSupplier(Timer timer, io.github.resilience4j.core.functions.CheckedSupplier<T> supplier)
      Decorates CheckedSupplier with Timer
      Type Parameters:
      T - the supplier result
      Parameters:
      timer - the timer
      supplier - the supplier
      Returns:
      decorated supplier
    • decorateCheckedRunnable

      static io.github.resilience4j.core.functions.CheckedRunnable decorateCheckedRunnable(Timer timer, io.github.resilience4j.core.functions.CheckedRunnable runnable)
      Decorates CheckedRunnable with Timer
      Parameters:
      timer - the timer
      runnable - the original runnable
      Returns:
      decorated runnable
    • decorateCheckedFunction

      static <T, R> io.github.resilience4j.core.functions.CheckedFunction<T,R> decorateCheckedFunction(Timer timer, io.github.resilience4j.core.functions.CheckedFunction<T,R> function)
      Decorates CheckedFunction with Timer
      Type Parameters:
      T - the type of the input to the function
      R - the result type of the function
      Parameters:
      timer - the timer
      function - the original function
      Returns:
      a decorated function
    • decorateSupplier

      static <T> Supplier<T> decorateSupplier(Timer timer, Supplier<T> supplier)
      Decorates Supplier with Timer
      Type Parameters:
      T - the type of results supplied by this supplier
      Parameters:
      timer - the timer
      supplier - the original supplier
      Returns:
      a decorated supplier
    • decorateCallable

      static <T> Callable<T> decorateCallable(Timer timer, Callable<T> callable)
      Decorates Callable with Timer
      Type Parameters:
      T - the type of results supplied by this callable
      Parameters:
      timer - the timer
      callable - the original callable
      Returns:
      a decorated callable
    • decorateRunnable

      static Runnable decorateRunnable(Timer timer, Runnable runnable)
      Decorates Runnable with Timer
      Parameters:
      timer - the timer
      runnable - the original runnable
      Returns:
      a decorated runnable
    • decorateFunction

      static <T, R> Function<T,R> decorateFunction(Timer timer, Function<T,R> function)
      Decorates Function with Timer
      Type Parameters:
      T - the type of the input to the function
      R - the result type of the function
      Parameters:
      timer - the timer
      function - the original function
      Returns:
      a decorated function
    • decorateConsumer

      static <T> Consumer<T> decorateConsumer(Timer timer, Consumer<T> consumer)
      Decorates Consumer with Timer
      Type Parameters:
      T - the type of the input to the consumer
      Parameters:
      timer - the timer
      consumer - the original consumer
      Returns:
      a decorated consumer
    • decorateCheckedConsumer

      static <T> io.github.resilience4j.core.functions.CheckedConsumer<T> decorateCheckedConsumer(Timer timer, io.github.resilience4j.core.functions.CheckedConsumer<T> consumer)
      Decorates CheckedConsumer with Timer
      Type Parameters:
      T - the type of the input to the consumer
      Parameters:
      timer - the timer
      consumer - the original consumer
      Returns:
      a decorated consumer
    • getName

      String getName()
      Returns the name of this Timer.
      Returns:
      the name of this Timer
    • getTimerConfig

      TimerConfig getTimerConfig()
      Returns the TimerConfig of this Timer.
      Returns:
      the TimerConfig of this Timer
    • getTags

      Map<String,String> getTags()
      Returns an unmodifiable map with tags assigned to this Timer.
      Returns:
      the tags assigned to this Timer in an unmodifiable map
    • executeCheckedSupplier

      default <T> T executeCheckedSupplier(io.github.resilience4j.core.functions.CheckedSupplier<T> checkedSupplier) throws Throwable
      Decorates and executes the decorated Supplier.
      Type Parameters:
      T - the type of results supplied by this supplier
      Parameters:
      checkedSupplier - the original Supplier
      Returns:
      the result of the decorated Supplier.
      Throws:
      Throwable - if something goes wrong applying this function to the given arguments
    • executeSupplier

      default <T> T executeSupplier(Supplier<T> supplier)
      Decorates and executes the decorated Supplier.
      Type Parameters:
      T - the type of results supplied by this supplier
      Parameters:
      supplier - the original Supplier
      Returns:
      the result of the decorated Supplier.
    • executeCallable

      default <T> T executeCallable(Callable<T> callable) throws Exception
      Decorates and executes the decorated Callable.
      Type Parameters:
      T - the result type of callable
      Parameters:
      callable - the original Callable
      Returns:
      the result of the decorated Callable.
      Throws:
      Exception
    • executeRunnable

      default void executeRunnable(Runnable runnable)
      Decorates and executes the decorated Runnable.
      Parameters:
      runnable - the original Runnable
    • executeCompletionStage

      default <T> CompletionStage<T> executeCompletionStage(Supplier<CompletionStage<T>> supplier)
      Decorates and executes the decorated CompletionStage.
      Type Parameters:
      T - the type of results supplied by this supplier
      Parameters:
      supplier - the original CompletionStage
      Returns:
      the decorated CompletionStage.
    • createContext

      Timer.Context createContext()
      Creates a Timer context and starts the timer.
      Returns:
      the Timer context
    • getEventPublisher

      Timer.EventPublisher getEventPublisher()
      Returns an EventPublisher can be used to register event consumers.
      Returns:
      an EventPublisher