Interface MetricsGateway

All Superinterfaces:
HasLocalHandlers
All Known Implementing Classes:
DefaultMetricsGateway

public interface MetricsGateway extends HasLocalHandlers
Gateway interface for publishing metrics messages in Flux Capacitor.

This gateway provides a convenient way to log and transmit application performance data, operational metrics, or monitoring signals. Metrics messages can be published either as raw payloads or as fully constructed Message objects. Metadata and delivery guarantees can also be specified.

Metrics are typically not routed for domain logic handling, but can be consumed by local handlers as well as non-local handlers (e.g., for logging or real-time telemetry).

Example usage:


 FluxCapacitor.publishMetrics(new SystemMetrics(...));
 
See Also:
  • Method Details

    • publish

      default void publish(Object metrics)
      Publishes a metrics message using default metadata and Guarantee.NONE.

      If the provided value is already a Message, its payload and metadata will be extracted. Otherwise, it is wrapped in a new Message.

      Parameters:
      metrics - the metrics object or Message to publish
    • publish

      default void publish(Object payload, Metadata metadata)
      Publishes a metrics payload with the specified metadata and a Guarantee.NONE delivery guarantee.
      Parameters:
      payload - the payload of the metrics message
      metadata - metadata to attach to the message
    • publish

      CompletableFuture<Void> publish(Object payload, Metadata metadata, Guarantee guarantee)
      Publishes a metrics message with the specified metadata and delivery guarantee.

      This method may complete asynchronously.

      Parameters:
      payload - the metrics payload
      metadata - metadata to attach to the message
      guarantee - delivery guarantee (e.g., Guarantee.SENT or Guarantee.STORED)
      Returns:
      a CompletableFuture that completes when the message is published (or not, depending on the guarantee)