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