Raxol.Core.Metrics (Raxol v2.0.1)
View SourceCore metrics module for Raxol framework.
This module provides basic metrics collection and recording functionality with pure functional error handling patterns.
Summary
Functions
Clears all recorded metrics.
Gets all recorded metrics.
Initializes the metrics system.
Records a metric with the given name, value, and optional tags.
Functions
@spec clear_metrics() :: :ok | {:error, {:metrics_clear_failed, :clear_collector_timeout | :clear_aggregator_timeout | {:clear_collector_exit, term()} | {:clear_aggregator_exit, term()}}}
Clears all recorded metrics.
Returns
:ok- Metrics cleared successfully{:error, reason}- Failed to clear metrics
Gets all recorded metrics.
Returns
{:ok, metrics}- Map of recorded metrics{:error, reason}- Failed to get metrics
Initializes the metrics system.
Parameters
options- Configuration options for metrics (optional)
Returns
:ok- Metrics system initialized successfully{:error, reason}- Failed to initialize metrics system
Records a metric with the given name, value, and optional tags.
Parameters
name- Metric namevalue- Metric value (number, string, or map)tags- Optional tags as keyword list
Returns
:ok- Metric recorded successfully{:error, reason}- Failed to record metric
Example
Raxol.Core.Metrics.record("render_time", 150, [component: "table"])
Raxol.Core.Metrics.record("user_action", "button_click", [screen: "main"])