Class DisableMetrics

java.lang.Object
io.fluxcapacitor.javaclient.tracking.metrics.DisableMetrics
All Implemented Interfaces:
BatchInterceptor, HandlerDecorator, HandlerInterceptor

public class DisableMetrics extends Object implements HandlerInterceptor, BatchInterceptor
Interceptor that disables the dispatch of outbound MessageType.METRICS messages.

This class implements both HandlerInterceptor and BatchInterceptor, allowing it to wrap individual message handlers as well as batch execution by message trackers. When applied, it uses an AdhocDispatchInterceptor to suppress the publication of metrics within the scope of the handler or batch execution.

Typical usage includes applying this interceptor to consumers that should not emit metrics, such as utility consumers that operate in high-frequency or low-signal environments.

Example Usage

To apply this interceptor, annotate your handler class using @Consumer(batchInterceptors = DisableMetrics.class) or @Consumer(handlerInterceptors = DisableMetrics.class):

 @Consumer(handlerInterceptors = DisableMetrics.class)
 public class OrderHandler {

     @HandleEvent
     public void on(OrderPlaced event) {
         // Any outbound metrics from this handler will be suppressed
     }
 }
 
See Also:
  • Constructor Details

    • DisableMetrics

      public DisableMetrics()
  • Method Details

    • intercept

      public Consumer<MessageBatch> intercept(Consumer<MessageBatch> consumer, Tracker tracker)
      Description copied from interface: BatchInterceptor
      Intercepts the given batch message consumer and returns a decorated version to be invoked by the tracker.
      Specified by:
      intercept in interface BatchInterceptor
      Parameters:
      consumer - the original consumer that processes the MessageBatch
      tracker - the tracker invoking this interceptor
      Returns:
      a wrapped consumer with additional behavior
    • interceptHandling

      public Function<DeserializingMessage,Object> interceptHandling(Function<DeserializingMessage,Object> function, HandlerInvoker invoker)
      Description copied from interface: HandlerInterceptor
      Intercepts the message handling logic.

      The function parameter represents the next step in the handling chain— typically the actual message handler. The invoker provides metadata and invocation logic for the underlying handler method.

      Within this method, an interceptor may:

      • Modify the DeserializingMessage before passing it to the handler
      • Bypass the handler entirely and return a value directly
      • Wrap the result after the handler is invoked

      Note: Interceptors may return a different DeserializingMessage, but it must be compatible with a handler method in the same target class. If no suitable handler is found, an exception will be thrown.

      Specified by:
      interceptHandling in interface HandlerInterceptor
      Parameters:
      function - the next step in the handler chain (typically the handler itself)
      invoker - the metadata and execution strategy for the actual handler method
      Returns:
      a decorated function that wraps handling behavior