1use crate::OtelGuard;
16use std::sync::{Arc, Mutex};
17use tokio::sync::SetError;
18
19#[derive(Debug, thiserror::Error)]
21pub enum GlobalError {
22 #[error("Failed to set a global recorder: {0}")]
28 SetRecorder(#[from] metrics::SetRecorderError<crate::Recorder>),
29 #[error("Failed to set global guard: {0}")]
30 SetError(#[from] SetError<Arc<Mutex<Option<OtelGuard>>>>),
31 #[error("Global guard not initialized")]
32 NotInitialized,
33 #[error("Global guard lock poisoned: {0}")]
34 GuardPoisoned(&'static str),
35 #[error("Global system metrics err: {0}")]
36 MetricsError(String),
37 #[error("Failed to get current PID: {0}")]
38 PidError(String),
39 #[error("Process with PID {0} not found")]
40 ProcessNotFound(u32),
41 #[error("Failed to get physical core count")]
42 CoreCountError,
43 #[error("GPU initialization failed: {0}")]
44 GpuInitError(String),
45 #[error("GPU device not found: {0}")]
46 GpuDeviceError(String),
47 #[error("Failed to send log: {0}")]
48 SendFailed(&'static str),
49 #[error("Operation timed out: {0}")]
50 Timeout(&'static str),
51 #[error("Telemetry initialization failed: {0}")]
52 TelemetryError(#[from] TelemetryError),
53}
54
55#[derive(Debug, thiserror::Error)]
56pub enum TelemetryError {
57 #[error("Span exporter build failed: {0}")]
58 BuildSpanExporter(String),
59 #[error("Metric exporter build failed: {0}")]
60 BuildMetricExporter(String),
61 #[error("Log exporter build failed: {0}")]
62 BuildLogExporter(String),
63 #[error("RUSTFS_OBS_TLS_CA_FILE must be an absolute path")]
64 OtlpTlsCaPathNotAbsolute,
65 #[error("Failed to read RUSTFS_OBS_TLS_CA_FILE")]
66 OtlpTlsCaRead(#[source] std::io::Error),
67 #[error("RUSTFS_OBS_TLS_CA_FILE does not contain a PEM certificate")]
68 OtlpTlsCaEmpty,
69 #[error("RUSTFS_OBS_TLS_CA_FILE does not contain a valid PEM certificate")]
70 OtlpTlsCaInvalid,
71 #[error("Failed to parse RUSTFS_OBS_TLS_CA_FILE as a PEM certificate bundle")]
72 OtlpTlsCaParse(#[source] reqwest::Error),
73 #[error("Failed to build OTLP HTTP client")]
74 BuildOtlpHttpClient(#[source] reqwest::Error),
75 #[error("Install metrics recorder failed: {0}")]
76 InstallMetricsRecorder(String),
77 #[error("Tracing subscriber init failed: {0}")]
78 SubscriberInit(String),
79 #[error("I/O error: {0}")]
80 Io(String),
81 #[error("Set permissions failed: {0}")]
82 SetPermissions(String),
83 #[error("Log sink conflict: {0}")]
84 LogSinkConflict(String),
85}
86
87impl From<std::io::Error> for TelemetryError {
88 fn from(e: std::io::Error) -> Self {
89 TelemetryError::Io(e.to_string())
90 }
91}