{"record":{"id":"69e4e786fd45263a","repo":"rustfs/rustfs","slug":"telemetry-initialization-failed-0","errorCode":null,"errorMessage":"Telemetry initialization failed: {0}","messagePattern":"Telemetry initialization failed: (.+?)","errorType":"exception","errorClass":"GlobalError","httpStatus":null,"severity":"error","filePath":"crates/obs/src/error.rs","lineNumber":51,"sourceCode":"    #[error(\"Global guard lock poisoned: {0}\")]\n    GuardPoisoned(&'static str),\n    #[error(\"Global system metrics err: {0}\")]\n    MetricsError(String),\n    #[error(\"Failed to get current PID: {0}\")]\n    PidError(String),\n    #[error(\"Process with PID {0} not found\")]\n    ProcessNotFound(u32),\n    #[error(\"Failed to get physical core count\")]\n    CoreCountError,\n    #[error(\"GPU initialization failed: {0}\")]\n    GpuInitError(String),\n    #[error(\"GPU device not found: {0}\")]\n    GpuDeviceError(String),\n    #[error(\"Failed to send log: {0}\")]\n    SendFailed(&'static str),\n    #[error(\"Operation timed out: {0}\")]\n    Timeout(&'static str),\n    #[error(\"Telemetry initialization failed: {0}\")]\n    TelemetryError(#[from] TelemetryError),\n}\n\n#[derive(Debug, thiserror::Error)]\npub enum TelemetryError {\n    #[error(\"Span exporter build failed: {0}\")]\n    BuildSpanExporter(String),\n    #[error(\"Metric exporter build failed: {0}\")]\n    BuildMetricExporter(String),\n    #[error(\"Log exporter build failed: {0}\")]\n    BuildLogExporter(String),\n    #[error(\"Install metrics recorder failed: {0}\")]\n    InstallMetricsRecorder(String),\n    #[error(\"Tracing subscriber init failed: {0}\")]\n    SubscriberInit(String),\n    #[error(\"I/O error: {0}\")]\n    Io(String),\n    #[error(\"Set permissions failed: {0}\")]","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/rustfs/rustfs/blob/35af688cd9d41b4346fbe27dcf7250ba72046c1f/crates/obs/src/error.rs#L33-L69","documentation":"GlobalError::TelemetryError(#[from] TelemetryError) is the transparent wrapper for the whole TelemetryError enum (crates/obs/src/error.rs:51). It surfaces whenever telemetry initialization fails: exporter construction (BuildSpanExporter/BuildMetricExporter/BuildLogExporter), recorder installation (InstallMetricsRecorder), subscriber setup (SubscriberInit), I/O (Io), log-file permissions (SetPermissions), or stdout conflicts (LogSinkConflict). The inner variant is the real diagnosis; treat this variant as a router.","triggerScenarios":"Calling the telemetry init API (otel.rs / local.rs init paths) with a config that fails at any stage — bad OTLP endpoint, unwritable log directory, conflicting stdout sink, or a double recorder install.","commonSituations":"Fresh deployments with unvalidated endpoint URLs; log_directory on read-only mounts or with wrong ownership; running the binary with stdout already captured in a way the local sink rejects; feature flags mismatch on exporters.","solutions":["Match on the inner TelemetryError variant first — each variant maps to a distinct fix (see the sibling entries)","Validate the telemetry config (endpoint URL, log directory writability, sink exclusivity) before init","Fail fast at startup: do not ignore this error and continue with telemetry silently absent"],"exampleFix":"// before\nlet result = obs::init_telemetry(&cfg);\nif result.is_err() { /* opaque handling */ }\n\n// after\nmatch obs::init_telemetry(&cfg) {\n    Ok(()) => {}\n    Err(GlobalError::TelemetryError(TelemetryError::BuildSpanExporter(e))) => {\n        return Err(format!(\"OTLP span endpoint invalid: {e}\"));\n    }\n    Err(other) => return Err(other.to_string()),\n}","handlingStrategy":"try-catch","validationCode":"// Validate the pieces init depends on before calling it:\nfn telemetry_config_sane(cfg: &ObsConfig) -> Result<(), String> {\n    if let Some(ep) = &cfg.otlp_endpoint {\n        url::Url::parse(ep).map_err(|e| format!(\"bad OTLP endpoint: {e}\"))?;\n    }\n    if let Some(dir) = &cfg.log_directory {\n        std::fs::create_dir_all(dir).map_err(|e| format!(\"log dir unusable: {e}\"))?;\n    }\n    Ok(())\n}","typeGuard":"fn is_telemetry_init_err(e: &GlobalError) -> bool {\n    matches!(e, GlobalError::TelemetryError(_))\n}","tryCatchPattern":"match obs::init_telemetry(&cfg) {\n    Ok(()) => Ok(()),\n    Err(GlobalError::TelemetryError(inner)) => match inner {\n        TelemetryError::BuildSpanExporter(m)\n        | TelemetryError::BuildMetricExporter(m)\n        | TelemetryError::BuildLogExporter(m) => Err(format!(\"fix OTLP config: {m}\")),\n        TelemetryError::SetPermissions(m) => Err(format!(\"fix log dir ownership: {m}\")),\n        other => Err(other.to_string()),\n    },\n    Err(e) => Err(e.to_string()),\n}","preventionTips":["Validate endpoint URLs and log-directory writability before init; each maps to a distinct inner variant","Fail fast on telemetry init errors in server binaries — silent absence costs more later","Learn the inner-variant map: exporter builds -> endpoint config, SetPermissions -> filesystem, LogSinkConflict -> stdout ownership"],"tags":["rust","observability","telemetry","initialization","error-envelopes"],"backgroundTag":"telemetry-initialization-failed","analyzedSha":"35af688cd9d41b4346fbe27dcf7250ba72046c1f","analyzedAt":"2026-08-20T21:57:04.799Z","contentChangedAt":"2026-08-20T21:57:04.799Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}