Expand description
Monitoring and metrics infrastructure for hybrid search.
This module provides comprehensive observability for the search system:
- Prometheus metrics for latency, throughput, and error tracking
- Structured logging with tracing
- Performance monitoring and alerting
§Metrics Exposed
maproom_search_query_latency_seconds- End-to-end search latency histogrammaproom_search_fusion_time_seconds- Score fusion computation time histogrammaproom_search_cache_hit_rate- Cache effectiveness gauge (0.0-1.0)maproom_search_result_count- Number of results returned per query histogrammaproom_search_errors_total- Counter for errors by typemaproom_search_queries_total- Total number of search queries counter
§Alert Thresholds
- p95 latency > 50ms: Performance degradation warning
- p95 latency > 100ms: Critical performance issue
- Error rate > 1%: Reliability issue warning
- Error rate > 5%: Critical reliability issue
- Cache hit rate < 50%: Cache effectiveness warning
§Usage
use maproom::metrics::{SearchMetrics, get_metrics};
use std::time::Instant;
#[tokio::main]
async fn main() {
let metrics = get_metrics();
let start = Instant::now();
// ... perform search ...
let duration = start.elapsed();
metrics.record_query_latency(duration.as_secs_f64(), "code", true);
metrics.record_result_count(10, "code");
metrics.increment_queries("code", true);
}Re-exports§
pub use cache_metrics::CacheMetrics;pub use performance::get_performance_metrics;pub use performance::PerformanceMetrics;pub use prometheus::init_metrics_server;pub use prometheus::metrics_handler;pub use search_metrics::get_metrics;pub use search_metrics::get_registry;pub use search_metrics::SearchMetrics;
Modules§
- cache_
metrics - Cache metrics tracking for embedding deduplication.
- performance
- Performance metrics collection for indexing, memory, and throughput.
- prometheus
- Prometheus metrics endpoint and HTTP server.
- search_
metrics - Search metrics collection and tracking.