Raxol.Core.Behaviours.Metrics behaviour (Raxol v2.0.1)

View Source

Common behavior for metrics collection and reporting.

This behavior defines a consistent interface for components that collect, track, and report metrics about their operation.

Summary

Callbacks

Records a gauge metric value.

Gets a specific metric value.

Gets all current metric values.

Records a histogram/timing metric.

Resets a specific metric to its initial value.

Resets all metrics to initial values.

Functions

Convenience functions with default implementations.

Types

metric_name()

@type metric_name() :: atom() | String.t()

metric_tags()

@type metric_tags() :: keyword()

metric_value()

@type metric_value() :: number()

metrics()

@type metrics() :: map()

Callbacks

decrement(metric_name, metric_value, metric_tags)

@callback decrement(metric_name(), metric_value(), metric_tags()) :: :ok

Decrements a counter metric.

gauge(metric_name, metric_value, metric_tags)

@callback gauge(metric_name(), metric_value(), metric_tags()) :: :ok

Records a gauge metric value.

get_metric(metric_name)

@callback get_metric(metric_name()) :: metric_value() | nil

Gets a specific metric value.

get_metrics()

@callback get_metrics() :: metrics()

Gets all current metric values.

histogram(metric_name, metric_value, metric_tags)

@callback histogram(metric_name(), metric_value(), metric_tags()) :: :ok

Records a histogram/timing metric.

increment(metric_name, metric_value, metric_tags)

@callback increment(metric_name(), metric_value(), metric_tags()) :: :ok

Increments a counter metric.

reset_metric(metric_name)

(optional)
@callback reset_metric(metric_name()) :: :ok

Resets a specific metric to its initial value.

reset_metrics()

(optional)
@callback reset_metrics() :: :ok

Resets all metrics to initial values.

Functions

__using__(opts)

(macro)

Convenience functions with default implementations.