Skip to main content

oxigeo_observability/
lib.rs

1//! OpenTelemetry-based observability, monitoring, and alerting for OxiGeo.
2//!
3//! This crate provides comprehensive observability capabilities for the OxiGeo
4//! geospatial data processing library, including:
5//!
6//! - **OpenTelemetry Integration**: Distributed tracing, metrics, and logs
7//! - **Custom Geospatial Metrics**: Raster, vector, I/O, cache, query, GPU, and cluster metrics
8//! - **Distributed Tracing**: W3C Trace Context propagation across services
9//! - **Real-time Dashboards**: Grafana and Prometheus dashboard templates
10//! - **Anomaly Detection**: Statistical and ML-based anomaly detection
11//! - **SLO/SLA Monitoring**: Service level objectives and error budget tracking
12//! - **Alert Management**: Rule-based alerting with routing and escalation
13//! - **Metric Exporters**: Prometheus, StatsD, InfluxDB, CloudWatch support
14//!
15//! # Example
16//!
17//! ```no_run
18//! use oxigeo_observability::telemetry::{TelemetryConfig, init_with_config};
19//!
20//! # tokio_test::block_on(async {
21//! // Initialize telemetry
22//! let config = TelemetryConfig::new("oxigeo")
23//!     .with_service_version("1.0.0")
24//!     .with_jaeger_endpoint("localhost:6831")
25//!     .with_sampling_rate(0.1);
26//!
27//! let provider = init_with_config(config).await.expect("Failed to initialize telemetry");
28//! # })
29//! ```
30
31#![warn(missing_docs)]
32#![allow(clippy::unwrap_used, clippy::expect_used)]
33#![allow(clippy::panic)]
34
35pub mod alerting;
36// `alerts` is a fully-documented rule-based `AlertEngine` (condition
37// evaluation, state machine, grouping/dedup, multi-channel notification,
38// silencing, history) that previously existed on disk but was never
39// declared here, so it never compiled, was never tested, and its
40// doc-comment usage example was never doctested. It has been audited and
41// wired in: the one hard compile error (a missing `regex` dependency, used
42// by `alerts::silence` for regex label matching) is fixed via this crate's
43// Cargo.toml, and `alerts::evaluator::ConditionExpression::LabelMatch` (the
44// only remaining stub -- it unconditionally returned `true`) now does a
45// real regex match against the label context passed to
46// `ConditionEvaluator::evaluate_with_labels`. `alerts::channels` was
47// hardened to match `alerting::routing`'s honest-error handling for
48// HTTP delivery (status-code checking, and an `ExporterFeatureDisabled`
49// error instead of a silent no-op when `http-exporter` is disabled).
50pub mod alerts;
51pub mod anomaly;
52pub mod config;
53pub mod correlation;
54pub mod dashboard;
55pub mod dashboards;
56pub mod error;
57pub mod exporters;
58pub mod health;
59pub mod integration;
60pub mod metrics;
61pub mod profiling;
62pub mod reporting;
63pub mod slo;
64pub mod telemetry;
65pub mod tracing;
66
67// Re-export commonly used types
68pub use error::{ObservabilityError, Result};
69pub use health::{HealthCheckManager, HealthStatus};
70pub use profiling::{ProfileStats, Profiler};
71pub use telemetry::{TelemetryConfig, TelemetryProvider};
72
73#[cfg(test)]
74mod tests {
75    use super::*;
76
77    #[test]
78    fn test_telemetry_config() {
79        let config = TelemetryConfig::new("test-service")
80            .with_service_version("1.0.0")
81            .with_sampling_rate(0.5);
82
83        assert_eq!(config.service_name, "test-service");
84        assert_eq!(config.service_version, "1.0.0");
85        assert_eq!(config.sampling_rate, 0.5);
86    }
87}