Raxol.Terminal.ScreenBuffer.Metrics (Raxol v0.5.0)

View Source

Handles metrics collection and management for the terminal screen buffer. This module provides functions for recording and retrieving various metrics related to screen buffer performance, operations, and resource usage.

Summary

Functions

Collects metrics of a specific type. Returns a map of metric names to their values.

Gets a metric value with optional tags. Returns the metric value if found, nil otherwise.

Gets metrics by type. Returns a map of metric names to their values for the specified type.

Gets the value of a specific metric. Returns the metric value and its associated tags.

Initializes a new metrics struct with default values.

Records a metric with optional tags. Returns a new metrics state with the metric recorded.

Records an operation metric. Returns a new metrics state with the operation metric updated.

Records a performance metric. Returns a new metrics state with the performance metric updated.

Records a resource metric. Returns a new metrics state with the resource metric updated.

Verifies if the given metrics exist in the state. Returns true if all metrics exist, false otherwise.

Types

metric_tags()

@type metric_tags() :: map()

metric_type()

@type metric_type() :: :performance | :operation | :resource

metric_value()

@type metric_value() :: number() | String.t() | boolean()

t()

@type t() :: %Raxol.Terminal.ScreenBuffer.Metrics{
  metrics: %{required(String.t()) => {metric_value(), metric_tags()}},
  operation_metrics: %{required(String.t()) => number()},
  performance_metrics: %{required(String.t()) => number()},
  resource_metrics: %{required(String.t()) => number()}
}

Functions

collect(state, atom)

@spec collect(t(), metric_type()) :: %{required(String.t()) => metric_value()}

Collects metrics of a specific type. Returns a map of metric names to their values.

get(state, metric, tags)

@spec get(t(), String.t(), metric_tags()) :: metric_value() | nil

Gets a metric value with optional tags. Returns the metric value if found, nil otherwise.

get_by_type(state, type)

@spec get_by_type(t(), metric_type()) :: %{required(String.t()) => metric_value()}

Gets metrics by type. Returns a map of metric names to their values for the specified type.

get_value(state, metric)

@spec get_value(t(), String.t()) :: {metric_value(), metric_tags()} | nil

Gets the value of a specific metric. Returns the metric value and its associated tags.

init()

Initializes a new metrics struct with default values.

record(state, metric, value, tags)

@spec record(t(), String.t(), metric_value(), metric_tags()) :: t()

Records a metric with optional tags. Returns a new metrics state with the metric recorded.

record_operation(state, operation, value)

@spec record_operation(t(), String.t(), number()) :: t()

Records an operation metric. Returns a new metrics state with the operation metric updated.

record_performance(state, metric, value)

@spec record_performance(t(), String.t(), number()) :: t()

Records a performance metric. Returns a new metrics state with the performance metric updated.

record_resource(state, resource, value)

@spec record_resource(t(), String.t(), number()) :: t()

Records a resource metric. Returns a new metrics state with the resource metric updated.

verify(state, metrics)

@spec verify(t(), [String.t()]) :: boolean()

Verifies if the given metrics exist in the state. Returns true if all metrics exist, false otherwise.