Skip to content

Commit f35e0ec

Browse files
committed
remove global error handler
1 parent afc8ff5 commit f35e0ec

File tree

3 files changed

+47
-88
lines changed

3 files changed

+47
-88
lines changed

opentelemetry/src/global/error_handler.rs

Lines changed: 0 additions & 86 deletions
This file was deleted.

opentelemetry/src/global/internal_logging.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
#![allow(unused_macros)]
2+
3+
#[cfg(feature = "logs")]
4+
use crate::logs::LogError;
5+
#[cfg(feature = "metrics")]
6+
use crate::metrics::MetricError;
7+
use crate::propagation::PropagationError;
8+
#[cfg(feature = "trace")]
9+
use crate::trace::TraceError;
10+
use std::sync::PoisonError;
11+
212
///
313
/// **Note**: These macros (`otel_info!`, `otel_warn!`, `otel_debug!`, and `otel_error!`) are intended to be used
414
/// **internally within OpenTelemetry code** or for **custom exporters and processors**. They are not designed
@@ -156,3 +166,39 @@ macro_rules! otel_error {
156166
}
157167
};
158168
}
169+
170+
/// Wrapper for error from tracing, log, and metrics part of open telemetry.
171+
#[derive(thiserror::Error, Debug)]
172+
#[non_exhaustive]
173+
pub enum Error {
174+
#[cfg(feature = "trace")]
175+
#[cfg_attr(docsrs, doc(cfg(feature = "trace")))]
176+
#[error(transparent)]
177+
/// Failed to export traces.
178+
Trace(#[from] TraceError),
179+
#[cfg(feature = "metrics")]
180+
#[cfg_attr(docsrs, doc(cfg(feature = "metrics")))]
181+
#[error(transparent)]
182+
/// An issue raised by the metrics module.
183+
Metric(#[from] MetricError),
184+
185+
#[cfg(feature = "logs")]
186+
#[cfg_attr(docsrs, doc(cfg(feature = "logs")))]
187+
#[error(transparent)]
188+
/// Failed to export logs.
189+
Log(#[from] LogError),
190+
191+
#[error(transparent)]
192+
/// Error happens when injecting and extracting information using propagators.
193+
Propagation(#[from] PropagationError),
194+
195+
#[error("{0}")]
196+
/// Other types of failures not covered by the variants above.
197+
Other(String),
198+
}
199+
200+
impl<T> From<PoisonError<T>> for Error {
201+
fn from(err: PoisonError<T>) -> Self {
202+
Error::Other(err.to_string())
203+
}
204+
}

opentelemetry/src/global/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@
130130
//! [`MeterProvider`]: crate::metrics::MeterProvider
131131
//! [`set_meter_provider`]: crate::global::set_meter_provider
132132
133-
mod error_handler;
134133
mod internal_logging;
135134
#[cfg(feature = "metrics")]
136135
mod metrics;
@@ -139,7 +138,7 @@ mod propagation;
139138
#[cfg(feature = "trace")]
140139
mod trace;
141140

142-
pub use error_handler::{handle_error, set_error_handler, Error};
141+
pub use internal_logging::Error;
143142
#[cfg(feature = "metrics")]
144143
#[cfg_attr(docsrs, doc(cfg(feature = "metrics")))]
145144
pub use metrics::*;

0 commit comments

Comments
 (0)