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 },
}
