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("Install metrics recorder failed: {0}")]
64 InstallMetricsRecorder(String),
65 #[error("Tracing subscriber init failed: {0}")]
66 SubscriberInit(String),
67 #[error("I/O error: {0}")]
68 Io(String),
69 #[error("Set permissions failed: {0}")]
70 SetPermissions(String),
71 #[error("Log sink conflict: {0}")]
72 LogSinkConflict(String),
73}
74
75impl From<std::io::Error> for TelemetryError {
76 fn from(e: std::io::Error) -> Self {
77 TelemetryError::Io(e.to_string())
78 }
79}