Class CapacityMonitor

java.lang.Object
org.axonframework.extension.metrics.micrometer.CapacityMonitor
All Implemented Interfaces:
MessageMonitor<Message>

public class CapacityMonitor extends Object implements MessageMonitor<Message>
Calculates capacity by tracking, within the configured time window, the average message processing time and multiplying that by the amount of messages processed.

The capacity can be more than 1 if the monitored message handler processes the messages in parallel. The capacity for a single threaded message handler will be a value between 0 and 1.

If the value for a single threaded message handler is 1 the component is active 100% of the time. This means that messages will have to wait to be processed.

Since:
4.1
Author:
Marijn van Zelst, Ivan Dugalic
  • Method Details

    • buildMonitor

      public static CapacityMonitor buildMonitor(String meterNamePrefix, io.micrometer.core.instrument.MeterRegistry meterRegistry)
      Creates a capacity monitor with the default time window 10 minutes
      Parameters:
      meterNamePrefix - The prefix for the meter name that will be created in the given meterRegistry
      meterRegistry - The meter registry used to create and register the meters
      Returns:
      The created capacity monitor
    • buildMonitor

      public static CapacityMonitor buildMonitor(String meterNamePrefix, io.micrometer.core.instrument.MeterRegistry meterRegistry, Function<Message,Iterable<io.micrometer.core.instrument.Tag>> tagsBuilder)
      Creates a capacity monitor with the default time window 10 minutes
      Parameters:
      meterNamePrefix - The prefix for the meter name that will be created in the given meterRegistry
      meterRegistry - The meter registry used to create and register the meters
      tagsBuilder - The function used to construct the list of micrometer Tag, based on the ingested message
      Returns:
      The created capacity monitor
    • buildMonitor

      public static CapacityMonitor buildMonitor(String meterNamePrefix, io.micrometer.core.instrument.MeterRegistry meterRegistry, long window, TimeUnit timeUnit)
      Creates a capacity monitor with the default system clock.
      Parameters:
      meterNamePrefix - The prefix for the meter name that will be created in the given meterRegistry
      meterRegistry - The meter registry used to create and register the meters
      window - The length of the window to measure the capacity over
      timeUnit - The temporal unit of the time window
      Returns:
      The created capacity monitor
    • buildMonitor

      public static CapacityMonitor buildMonitor(String meterNamePrefix, io.micrometer.core.instrument.MeterRegistry meterRegistry, long window, TimeUnit timeUnit, Function<Message,Iterable<io.micrometer.core.instrument.Tag>> tagsBuilder)
      Creates a capacity monitor with the default system clock.
      Parameters:
      meterNamePrefix - The prefix for the meter name that will be created in the given meterRegistry
      meterRegistry - The meter registry used to create and register the meters
      window - The length of the window to measure the capacity over
      timeUnit - The temporal unit of the time window
      tagsBuilder - The function used to construct the list of micrometer Tag, based on the ingested message
      Returns:
      The created capacity monitor
    • buildMonitor

      public static CapacityMonitor buildMonitor(String meterNamePrefix, io.micrometer.core.instrument.MeterRegistry meterRegistry, long window, TimeUnit timeUnit, io.micrometer.core.instrument.Clock clock)
      Creates a capacity monitor with the given time window. Uses the provided clock to measure process time per message.
      Parameters:
      meterNamePrefix - The prefix for the meter name that will be created in the given meterRegistry
      meterRegistry - The meter registry used to create and register the meters
      window - The length of the window to measure the capacity over
      timeUnit - The temporal unit of the time window
      clock - The clock used to measure the process time per message
      Returns:
      The created capacity monitor
    • buildMonitor

      public static CapacityMonitor buildMonitor(String meterNamePrefix, io.micrometer.core.instrument.MeterRegistry meterRegistry, long window, TimeUnit timeUnit, io.micrometer.core.instrument.Clock clock, Function<Message,Iterable<io.micrometer.core.instrument.Tag>> tagsBuilder)
      Creates a capacity monitor with the given time window. Uses the provided clock to measure process time per message.
      Parameters:
      meterNamePrefix - The prefix for the meter name that will be created in the given meterRegistry
      meterRegistry - The meter registry used to create and register the meters
      window - The length of the window to measure the capacity over
      timeUnit - The temporal unit of the time window
      clock - The clock used to measure the process time per message
      tagsBuilder - The function used to construct the list of micrometer Tag, based on the ingested message
      Returns:
      The created capacity monitor
    • onMessageIngested

      public MessageMonitor.MonitorCallback onMessageIngested(@Nonnull Message message)
      Description copied from interface: MessageMonitor
      Takes a message and returns a callback that should be used to inform the message monitor about the result of processing the message
      Specified by:
      onMessageIngested in interface MessageMonitor<Message>
      Parameters:
      message - the message to monitor
      Returns:
      the callback