|
1 | 1 | //! Wrapper for error from trace, logs and metrics part of open telemetry. |
2 | | -use std::sync::PoisonError; |
3 | | - |
4 | | -#[cfg(feature = "logs")] |
5 | | -use crate::logs::LogError; |
6 | | -#[cfg(feature = "metrics")] |
7 | | -use crate::metrics::MetricError; |
8 | | -use opentelemetry::propagation::PropagationError; |
9 | | -#[cfg(feature = "trace")] |
10 | | -use opentelemetry::trace::TraceError; |
11 | | - |
12 | | -/// Wrapper for error from both tracing and metrics part of open telemetry. |
13 | | -#[derive(thiserror::Error, Debug)] |
14 | | -#[non_exhaustive] |
15 | | -pub enum Error { |
16 | | - #[cfg(feature = "trace")] |
17 | | - #[cfg_attr(docsrs, doc(cfg(feature = "trace")))] |
18 | | - #[error(transparent)] |
19 | | - /// Failed to export traces. |
20 | | - Trace(#[from] TraceError), |
21 | | - #[cfg(feature = "metrics")] |
22 | | - #[cfg_attr(docsrs, doc(cfg(feature = "metrics")))] |
23 | | - #[error(transparent)] |
24 | | - /// An issue raised by the metrics module. |
25 | | - Metric(#[from] MetricError), |
26 | | - |
27 | | - #[cfg(feature = "logs")] |
28 | | - #[cfg_attr(docsrs, doc(cfg(feature = "logs")))] |
29 | | - #[error(transparent)] |
30 | | - /// Failed to export logs. |
31 | | - Log(#[from] LogError), |
32 | | - |
33 | | - #[error(transparent)] |
34 | | - /// Error happens when injecting and extracting information using propagators. |
35 | | - Propagation(#[from] PropagationError), |
36 | | - |
37 | | - #[error("{0}")] |
38 | | - /// Other types of failures not covered by the variants above. |
39 | | - Other(String), |
40 | | -} |
41 | | - |
42 | | -impl<T> From<PoisonError<T>> for Error { |
43 | | - fn from(err: PoisonError<T>) -> Self { |
44 | | - Error::Other(err.to_string()) |
45 | | - } |
46 | | -} |
47 | 2 |
|
48 | 3 | /// Trait for errors returned by exporters |
49 | 4 | pub trait ExportError: std::error::Error + Send + Sync + 'static { |
|
0 commit comments