API Reference - Metrics¶
Core Metric Classes¶
EventMetrics¶
- class EventMetrics¶
Metrics for a single event execution.
Attributes:
- event_name: str¶
Name of the event being tracked.
- task_id: str¶
ID of the task instance.
- start_time: float¶
Event start timestamp.
- end_time: float¶
Event completion timestamp.
- status: str¶
Current execution status.
- error: str | None¶
Error message if failed.
- retry_count: int¶
Number of retry attempts.
- process_id: int | None¶
Process ID executing the event.
NetworkMetrics¶
- class NetworkMetrics¶
Metrics for network operations.
Attributes:
- operation: str¶
Type of network operation.
- host: str¶
Remote host address.
- port: int¶
Remote port number.
- start_time: float¶
Operation start timestamp.
- end_time: float¶
Operation completion timestamp.
- bytes_sent: int¶
Number of bytes sent.
- bytes_received: int¶
Number of bytes received.
- error: str | None¶
Error message if failed.
Publisher Classes¶
MetricsPublisher¶
- class MetricsPublisher¶
Base interface for metrics publishing adapters.
Methods:
- publish_event_metrics(metrics: EventMetrics) None¶
Publishes event metrics to backend system.
- Parameters:
metrics (EventMetrics) – Event metrics to publish
- publish_network_metrics(metrics: dict) None¶
Publishes network metrics to backend system.
- Parameters:
metrics (dict) – Network metrics to publish
- format_metrics(metrics: EventMetrics | dict) dict¶
Formats metrics into standardized dictionary.
- Parameters:
metrics – Metrics to format
- Returns:
Formatted metrics dictionary
- Return type:
dict
ElasticsearchPublisher¶
- class ElasticsearchPublisher¶
Publishes metrics to Elasticsearch.
Parameters:
- Parameters:
hosts (List[str]) – List of Elasticsearch hosts
index_prefix (str) – Prefix for metrics indices
kwargs – Additional client options
PrometheusPublisher¶
- class PrometheusPublisher¶
Exposes metrics for Prometheus scraping.
Parameters:
- Parameters:
port (int) – Port to expose metrics on
Metrics Exposed:
event_duration_seconds (Histogram)
event_retries_total (Counter)
network_bytes_total (Counter)
network_latency_seconds (Histogram)
GrafanaCloudPublisher¶
- class GrafanaCloudPublisher¶
Publishes metrics to Grafana Cloud.
Parameters:
- Parameters:
api_key (str) – Grafana Cloud API key
org_slug (str) – Organization identifier
region (str) – Cloud region
CompositePublisher¶
- class CompositePublisher¶
Publishes metrics to multiple backends.
Parameters:
- Parameters:
publishers (List[MetricsPublisher]) – List of publisher instances