opentelemetry_sdk/metrics/
error.rs1use std::result;
2use std::sync::PoisonError;
3use thiserror::Error;
4
5use crate::ExportError;
6
7pub type MetricResult<T> = result::Result<T, MetricError>;
9
10#[derive(Error, Debug)]
12#[non_exhaustive]
13pub enum MetricError {
14 #[error("Metrics error: {0}")]
16 Other(String),
17 #[error("Config error {0}")]
19 Config(String),
20 #[error("Metrics exporter {0} failed with {name}", name = .0.exporter_name())]
22 ExportErr(Box<dyn ExportError>),
23 #[error("Invalid instrument configuration: {0}")]
27 InvalidInstrumentConfiguration(&'static str),
28}
29
30impl<T: ExportError> From<T> for MetricError {
31 fn from(err: T) -> Self {
32 MetricError::ExportErr(Box::new(err))
33 }
34}
35
36impl<T> From<PoisonError<T>> for MetricError {
37 fn from(err: PoisonError<T>) -> Self {
38 MetricError::Other(err.to_string())
39 }
40}