ExMCP.Transport.Beam.Observability (ex_mcp v0.10.0)

View Source

Observability module for BEAM transport providing metrics collection, health monitoring, distributed tracing, and alerting capabilities.

This module implements comprehensive observability features for the enhanced BEAM transport to enable monitoring, debugging, and performance analysis.

Features

  • Metrics collection and aggregation
  • Health monitoring and status checks
  • Distributed tracing correlation
  • Real-time alerting and notifications
  • Performance analytics
  • Resource usage tracking

Summary

Functions

Returns a specification to start this module under a supervisor.

Gets all active traces.

Gets comprehensive statistics including derived metrics.

Gets current metrics.

Gets traces for a specific trace ID.

Performs a health check.

Performs a health check on a specific server.

Records an error event.

Records a message received event.

Records a message sent event.

Records a metric value.

Records a trace span.

Resets all metrics to zero.

Sets an alert handler function.

Starts the observability manager.

Triggers an alert.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_active_traces()

@spec get_active_traces() :: {:ok, list()}

Gets all active traces.

get_comprehensive_stats()

@spec get_comprehensive_stats() :: {:ok, map()}

Gets comprehensive statistics including derived metrics.

get_metrics()

@spec get_metrics() :: {:ok, map()}

Gets current metrics.

get_traces(trace_id)

@spec get_traces(String.t()) :: {:ok, list()}

Gets traces for a specific trace ID.

health_check()

@spec health_check() :: {:ok, :healthy | :unhealthy}

Performs a health check.

health_check(server)

@spec health_check(term()) :: {:ok, :healthy | :unhealthy}

Performs a health check on a specific server.

record_error(error_type)

@spec record_error(atom()) :: :ok

Records an error event.

record_message_received(byte_size, latency_ms)

@spec record_message_received(non_neg_integer(), non_neg_integer()) :: :ok

Records a message received event.

record_message_sent(byte_size)

@spec record_message_sent(non_neg_integer()) :: :ok

Records a message sent event.

record_metric(metric_name, value)

@spec record_metric(atom(), number()) :: :ok

Records a metric value.

record_trace(trace_id, span_data)

@spec record_trace(String.t(), map()) :: :ok

Records a trace span.

reset_metrics()

@spec reset_metrics() :: :ok

Resets all metrics to zero.

set_alert_handler(handler_fn)

@spec set_alert_handler(function()) :: :ok

Sets an alert handler function.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Starts the observability manager.

trigger_alert(alert_data)

@spec trigger_alert(map()) :: :ok

Triggers an alert.