Observability Metrics
Comprehensive metrics collection and monitoring system for RecoAgent applications.
Overview
The observability metrics system provides detailed metrics collection, aggregation, and monitoring capabilities for all aspects of RecoAgent operations.
Core Features
- Custom Metrics: Define and collect custom metrics
- System Metrics: CPU, memory, disk usage monitoring
- Application Metrics: Request rates, response times, error rates
- Business Metrics: User engagement, conversion rates
- Alerting: Automated alerts based on metric thresholds
Usage Examples
Basic Metrics Collection
from recoagent.observability.metrics import MetricsCollector
# Create metrics collector
metrics_collector = MetricsCollector()
# Record custom metric
metrics_collector.record_counter("queries_processed", 1)
metrics_collector.record_gauge("active_users", 150)
metrics_collector.record_histogram("response_time", 1.5)
Advanced Metrics
# Create custom metrics
custom_metrics = metrics_collector.create_custom_metrics({
"user_satisfaction": "gauge",
"api_errors": "counter",
"processing_time": "histogram"
})
# Record metrics
custom_metrics.user_satisfaction.set(0.85)
custom_metrics.api_errors.inc()
custom_metrics.processing_time.observe(2.3)
API Reference
MetricsCollector Methods
record_counter(name: str, value: float) -> None
Record counter metric
Parameters:
name(str): Metric namevalue(float): Counter value
record_gauge(name: str, value: float) -> None
Record gauge metric
Parameters:
name(str): Metric namevalue(float): Gauge value
See Also
- Observability Tracing - Distributed tracing
- Observability Logging - Logging configuration