Skip to main content

rs_zero/observability/
config.rs

1use std::time::Duration;
2
3/// Observability configuration for rs-zero applications.
4#[derive(Debug, Clone, PartialEq, Eq, Default)]
5pub struct ObservabilityConfig {
6    /// Metrics exporter configuration.
7    pub metrics: MetricsConfig,
8    /// OpenTelemetry tracing configuration.
9    pub tracing: OpenTelemetryConfig,
10}
11
12/// Prometheus metrics configuration.
13#[derive(Debug, Clone, PartialEq, Eq)]
14pub struct MetricsConfig {
15    /// Whether metrics should be recorded.
16    pub enabled: bool,
17    /// HTTP path used by the metrics router helper.
18    pub path: String,
19}
20
21impl Default for MetricsConfig {
22    fn default() -> Self {
23        Self {
24            enabled: true,
25            path: "/metrics".to_string(),
26        }
27    }
28}
29
30/// OpenTelemetry tracing configuration.
31#[derive(Debug, Clone, PartialEq, Eq)]
32pub struct OpenTelemetryConfig {
33    /// Exporter mode.
34    pub exporter: TraceExporter,
35    /// Env filter directive.
36    pub filter: String,
37    /// Batch timeout for future OTLP exporter integration.
38    pub timeout: Duration,
39}
40
41impl Default for OpenTelemetryConfig {
42    fn default() -> Self {
43        Self {
44            exporter: TraceExporter::Disabled,
45            filter: "info".to_string(),
46            timeout: Duration::from_secs(5),
47        }
48    }
49}
50
51/// Supported tracing exporter modes.
52#[derive(Debug, Clone, PartialEq, Eq)]
53pub enum TraceExporter {
54    /// Do not install a tracing subscriber.
55    Disabled,
56    /// Export spans to stdout through `tracing-subscriber`.
57    Stdout,
58    /// Configure an OTLP endpoint. The current MVP validates configuration and
59    /// keeps transport setup explicit for application code.
60    Otlp { endpoint: String },
61}