Metrics

object Metrics

Central utility object for metrics collection and tagging in the Wow framework. Provides constants for metric keys, extension functions for reactive streams tagging, and factory methods to wrap components with metric decorators.

This object serves as the main entry point for enabling metrics collection across all Wow components like command buses, event buses, handlers, and repositories.

Properties

Link copied to clipboard

Metric tag key for aggregate names

Link copied to clipboard
const val COMMAND_KEY: String

Metric tag key for command names

Link copied to clipboard

Flag indicating whether metrics collection is enabled. Can be controlled via the system property "wow.metrics.enabled" (defaults to true).

Link copied to clipboard
const val EVENT_KEY: String

Metric tag key for event names

Link copied to clipboard

Metric tag key for processor names

Link copied to clipboard
const val SOURCE_KEY: String

Metric tag key for source component identification

Link copied to clipboard

Context key for storing metrics subscriber information in reactive contexts

Link copied to clipboard

Metric tag key for subscriber identification

Functions

Link copied to clipboard
fun ContextView.getMetricsSubscriber(): String?

Retrieves the metrics subscriber identifier from the reactive context.

Link copied to clipboard
fun <T : Any> T.metrizable(): T

Automatically wraps supported Wow components with their corresponding metric decorators. This function inspects the type of the component and applies the appropriate metric wrapper if metrics are enabled and the component is not already metrizable.

Wraps a DistributedCommandBus with metrics collection capabilities. Returns a MetricDistributedCommandBus that collects metrics on command operations.

Wraps a LocalCommandBus with metrics collection capabilities. Returns a MetricLocalCommandBus that collects metrics on command operations.

Wraps a DistributedDomainEventBus with metrics collection capabilities. Returns a MetricDistributedDomainEventBus that collects metrics on domain event operations.

Wraps a DomainEventHandler with metrics collection capabilities. Returns a MetricDomainEventHandler that collects metrics on domain event handling operations.

Wraps a LocalDomainEventBus with metrics collection capabilities. Returns a MetricLocalDomainEventBus that collects metrics on domain event operations.

Wraps an EventStore with metrics collection capabilities. Returns a MetricEventStore that collects metrics on event storage operations.

Wraps a SnapshotHandler with metrics collection capabilities. Returns a MetricSnapshotHandler that collects metrics on snapshot handling operations.

Wraps a SnapshotRepository with metrics collection capabilities. Returns a MetricSnapshotRepository that collects metrics on snapshot storage operations.

Wraps a SnapshotStrategy with metrics collection capabilities. Returns a MetricSnapshotStrategy that collects metrics on snapshot strategy operations.

Wraps a DistributedStateEventBus with metrics collection capabilities. Returns a MetricDistributedStateEventBus that collects metrics on state event operations.

Wraps a LocalStateEventBus with metrics collection capabilities. Returns a MetricLocalStateEventBus that collects metrics on state event operations.

Wraps a CommandHandler with metrics collection capabilities. Returns a MetricCommandHandler that collects metrics on command handling operations.

Wraps a ProjectionHandler with metrics collection capabilities. Returns a MetricProjectionHandler that collects metrics on projection handling operations.

Wraps a StatelessSagaHandler with metrics collection capabilities. Returns a MetricStatelessSagaHandler that collects metrics on saga handling operations.

inline fun <T> T.metrizable(block: (T) -> T): T

Conditionally applies a metric decorator to a component based on configuration. This function checks if metrics are enabled and if the component is not already metrizable before applying the provided decoration block.

Link copied to clipboard
fun Context.setMetricsSubscriber(metricsSubscriber: String): Context

Sets the metrics subscriber identifier in the reactive context.

Link copied to clipboard
fun <T> Flux<T>.tagMetricsSubscriber(): Flux<T>

Tags a Flux stream with subscriber information from the reactive context. If no subscriber is present in the context, applies default metrics without subscriber tagging.

Link copied to clipboard
fun <T> Flux<T>.writeMetricsSubscriber(metricsSubscriber: String): Flux<T>

Writes the metrics subscriber identifier to the reactive context of a Flux stream.