From f35e0ece3491c65865cfb3a366827cfa18c91349 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Mon, 28 Oct 2024 11:56:11 -0700 Subject: [PATCH 01/12] remove global error handler --- opentelemetry/src/global/error_handler.rs | 86 -------------------- opentelemetry/src/global/internal_logging.rs | 46 +++++++++++ opentelemetry/src/global/mod.rs | 3 +- 3 files changed, 47 insertions(+), 88 deletions(-) delete mode 100644 opentelemetry/src/global/error_handler.rs diff --git a/opentelemetry/src/global/error_handler.rs b/opentelemetry/src/global/error_handler.rs deleted file mode 100644 index 3a717154bf..0000000000 --- a/opentelemetry/src/global/error_handler.rs +++ /dev/null @@ -1,86 +0,0 @@ -use std::sync::PoisonError; -use std::sync::RwLock; - -#[cfg(feature = "logs")] -use crate::logs::LogError; -#[cfg(feature = "metrics")] -use crate::metrics::MetricError; -use crate::propagation::PropagationError; -#[cfg(feature = "trace")] -use crate::trace::TraceError; -use once_cell::sync::Lazy; - -static GLOBAL_ERROR_HANDLER: Lazy>> = Lazy::new(|| RwLock::new(None)); - -/// Wrapper for error from both tracing and metrics part of open telemetry. -#[derive(thiserror::Error, Debug)] -#[non_exhaustive] -pub enum Error { - #[cfg(feature = "trace")] - #[cfg_attr(docsrs, doc(cfg(feature = "trace")))] - #[error(transparent)] - /// Failed to export traces. - Trace(#[from] TraceError), - #[cfg(feature = "metrics")] - #[cfg_attr(docsrs, doc(cfg(feature = "metrics")))] - #[error(transparent)] - /// An issue raised by the metrics module. - Metric(#[from] MetricError), - - #[cfg(feature = "logs")] - #[cfg_attr(docsrs, doc(cfg(feature = "logs")))] - #[error(transparent)] - /// Failed to export logs. - Log(#[from] LogError), - - #[error(transparent)] - /// Error happens when injecting and extracting information using propagators. - Propagation(#[from] PropagationError), - - #[error("{0}")] - /// Other types of failures not covered by the variants above. - Other(String), -} - -impl From> for Error { - fn from(err: PoisonError) -> Self { - Error::Other(err.to_string()) - } -} - -struct ErrorHandler(Box); - -/// Handle error using the globally configured error handler. -/// -/// Writes to stderr if unset. -pub fn handle_error>(err: T) { - match GLOBAL_ERROR_HANDLER.read() { - Ok(handler) if handler.is_some() => (handler.as_ref().unwrap().0)(err.into()), - _ => match err.into() { - #[cfg(feature = "metrics")] - #[cfg_attr(docsrs, doc(cfg(feature = "metrics")))] - Error::Metric(err) => eprintln!("OpenTelemetry metrics error occurred. {}", err), - #[cfg(feature = "trace")] - #[cfg_attr(docsrs, doc(cfg(feature = "trace")))] - Error::Trace(err) => eprintln!("OpenTelemetry trace error occurred. {}", err), - #[cfg(feature = "logs")] - #[cfg_attr(docsrs, doc(cfg(feature = "logs")))] - Error::Log(err) => eprintln!("OpenTelemetry log error occurred. {}", err), - Error::Propagation(err) => { - eprintln!("OpenTelemetry propagation error occurred. {}", err) - } - Error::Other(err_msg) => eprintln!("OpenTelemetry error occurred. {}", err_msg), - }, - } -} - -/// Set global error handler. -pub fn set_error_handler(f: F) -> std::result::Result<(), Error> -where - F: Fn(Error) + Send + Sync + 'static, -{ - GLOBAL_ERROR_HANDLER - .write() - .map(|mut handler| *handler = Some(ErrorHandler(Box::new(f)))) - .map_err(Into::into) -} diff --git a/opentelemetry/src/global/internal_logging.rs b/opentelemetry/src/global/internal_logging.rs index 4391485619..401504847b 100644 --- a/opentelemetry/src/global/internal_logging.rs +++ b/opentelemetry/src/global/internal_logging.rs @@ -1,4 +1,14 @@ #![allow(unused_macros)] + +#[cfg(feature = "logs")] +use crate::logs::LogError; +#[cfg(feature = "metrics")] +use crate::metrics::MetricError; +use crate::propagation::PropagationError; +#[cfg(feature = "trace")] +use crate::trace::TraceError; +use std::sync::PoisonError; + /// /// **Note**: These macros (`otel_info!`, `otel_warn!`, `otel_debug!`, and `otel_error!`) are intended to be used /// **internally within OpenTelemetry code** or for **custom exporters and processors**. They are not designed @@ -156,3 +166,39 @@ macro_rules! otel_error { } }; } + +/// Wrapper for error from tracing, log, and metrics part of open telemetry. +#[derive(thiserror::Error, Debug)] +#[non_exhaustive] +pub enum Error { + #[cfg(feature = "trace")] + #[cfg_attr(docsrs, doc(cfg(feature = "trace")))] + #[error(transparent)] + /// Failed to export traces. + Trace(#[from] TraceError), + #[cfg(feature = "metrics")] + #[cfg_attr(docsrs, doc(cfg(feature = "metrics")))] + #[error(transparent)] + /// An issue raised by the metrics module. + Metric(#[from] MetricError), + + #[cfg(feature = "logs")] + #[cfg_attr(docsrs, doc(cfg(feature = "logs")))] + #[error(transparent)] + /// Failed to export logs. + Log(#[from] LogError), + + #[error(transparent)] + /// Error happens when injecting and extracting information using propagators. + Propagation(#[from] PropagationError), + + #[error("{0}")] + /// Other types of failures not covered by the variants above. + Other(String), +} + +impl From> for Error { + fn from(err: PoisonError) -> Self { + Error::Other(err.to_string()) + } +} diff --git a/opentelemetry/src/global/mod.rs b/opentelemetry/src/global/mod.rs index 4fada1123a..180f721ce1 100644 --- a/opentelemetry/src/global/mod.rs +++ b/opentelemetry/src/global/mod.rs @@ -130,7 +130,6 @@ //! [`MeterProvider`]: crate::metrics::MeterProvider //! [`set_meter_provider`]: crate::global::set_meter_provider -mod error_handler; mod internal_logging; #[cfg(feature = "metrics")] mod metrics; @@ -139,7 +138,7 @@ mod propagation; #[cfg(feature = "trace")] mod trace; -pub use error_handler::{handle_error, set_error_handler, Error}; +pub use internal_logging::Error; #[cfg(feature = "metrics")] #[cfg_attr(docsrs, doc(cfg(feature = "metrics")))] pub use metrics::*; From dc1994b1cc30c6f051d03f4c7bd3e63290475425 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Mon, 28 Oct 2024 13:00:04 -0700 Subject: [PATCH 02/12] bring back error_handler.rs, and remove the error_handler from there --- opentelemetry/src/global/error_handler.rs | 46 ++++++++++++++++++++ opentelemetry/src/global/internal_logging.rs | 46 -------------------- opentelemetry/src/global/mod.rs | 3 +- 3 files changed, 48 insertions(+), 47 deletions(-) create mode 100644 opentelemetry/src/global/error_handler.rs diff --git a/opentelemetry/src/global/error_handler.rs b/opentelemetry/src/global/error_handler.rs new file mode 100644 index 0000000000..76ad4160b8 --- /dev/null +++ b/opentelemetry/src/global/error_handler.rs @@ -0,0 +1,46 @@ +use std::sync::PoisonError; +use std::sync::RwLock; + +#[cfg(feature = "logs")] +use crate::logs::LogError; +#[cfg(feature = "metrics")] +use crate::metrics::MetricError; +use crate::propagation::PropagationError; +#[cfg(feature = "trace")] +use crate::trace::TraceError; + +/// Wrapper for error from both tracing and metrics part of open telemetry. +#[derive(thiserror::Error, Debug)] +#[non_exhaustive] +pub enum Error { + #[cfg(feature = "trace")] + #[cfg_attr(docsrs, doc(cfg(feature = "trace")))] + #[error(transparent)] + /// Failed to export traces. + Trace(#[from] TraceError), + #[cfg(feature = "metrics")] + #[cfg_attr(docsrs, doc(cfg(feature = "metrics")))] + #[error(transparent)] + /// An issue raised by the metrics module. + Metric(#[from] MetricError), + + #[cfg(feature = "logs")] + #[cfg_attr(docsrs, doc(cfg(feature = "logs")))] + #[error(transparent)] + /// Failed to export logs. + Log(#[from] LogError), + + #[error(transparent)] + /// Error happens when injecting and extracting information using propagators. + Propagation(#[from] PropagationError), + + #[error("{0}")] + /// Other types of failures not covered by the variants above. + Other(String), +} + +impl From> for Error { + fn from(err: PoisonError) -> Self { + Error::Other(err.to_string()) + } +} diff --git a/opentelemetry/src/global/internal_logging.rs b/opentelemetry/src/global/internal_logging.rs index 401504847b..4391485619 100644 --- a/opentelemetry/src/global/internal_logging.rs +++ b/opentelemetry/src/global/internal_logging.rs @@ -1,14 +1,4 @@ #![allow(unused_macros)] - -#[cfg(feature = "logs")] -use crate::logs::LogError; -#[cfg(feature = "metrics")] -use crate::metrics::MetricError; -use crate::propagation::PropagationError; -#[cfg(feature = "trace")] -use crate::trace::TraceError; -use std::sync::PoisonError; - /// /// **Note**: These macros (`otel_info!`, `otel_warn!`, `otel_debug!`, and `otel_error!`) are intended to be used /// **internally within OpenTelemetry code** or for **custom exporters and processors**. They are not designed @@ -166,39 +156,3 @@ macro_rules! otel_error { } }; } - -/// Wrapper for error from tracing, log, and metrics part of open telemetry. -#[derive(thiserror::Error, Debug)] -#[non_exhaustive] -pub enum Error { - #[cfg(feature = "trace")] - #[cfg_attr(docsrs, doc(cfg(feature = "trace")))] - #[error(transparent)] - /// Failed to export traces. - Trace(#[from] TraceError), - #[cfg(feature = "metrics")] - #[cfg_attr(docsrs, doc(cfg(feature = "metrics")))] - #[error(transparent)] - /// An issue raised by the metrics module. - Metric(#[from] MetricError), - - #[cfg(feature = "logs")] - #[cfg_attr(docsrs, doc(cfg(feature = "logs")))] - #[error(transparent)] - /// Failed to export logs. - Log(#[from] LogError), - - #[error(transparent)] - /// Error happens when injecting and extracting information using propagators. - Propagation(#[from] PropagationError), - - #[error("{0}")] - /// Other types of failures not covered by the variants above. - Other(String), -} - -impl From> for Error { - fn from(err: PoisonError) -> Self { - Error::Other(err.to_string()) - } -} diff --git a/opentelemetry/src/global/mod.rs b/opentelemetry/src/global/mod.rs index 180f721ce1..5f27b0e08b 100644 --- a/opentelemetry/src/global/mod.rs +++ b/opentelemetry/src/global/mod.rs @@ -130,6 +130,7 @@ //! [`MeterProvider`]: crate::metrics::MeterProvider //! [`set_meter_provider`]: crate::global::set_meter_provider +mod error_handler; mod internal_logging; #[cfg(feature = "metrics")] mod metrics; @@ -137,8 +138,8 @@ mod metrics; mod propagation; #[cfg(feature = "trace")] mod trace; +pub use error_handler::Error; -pub use internal_logging::Error; #[cfg(feature = "metrics")] #[cfg_attr(docsrs, doc(cfg(feature = "metrics")))] pub use metrics::*; From 9cf5898ff0c78ddfcc2c958175fb5a9125c5c08b Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Fri, 1 Nov 2024 10:45:46 -0700 Subject: [PATCH 03/12] initial commit --- .../src/error.rs | 5 +- opentelemetry-sdk/src/export/logs/mod.rs | 2 +- opentelemetry-sdk/src/export/mod.rs | 6 +- opentelemetry-sdk/src/lib.rs | 2 + opentelemetry-sdk/src/logs/error.rs | 63 ++++++++++++++++++ opentelemetry-sdk/src/logs/log_emitter.rs | 8 +-- opentelemetry-sdk/src/logs/log_processor.rs | 7 +- opentelemetry-sdk/src/logs/mod.rs | 2 + opentelemetry-sdk/src/metrics/aggregation.rs | 2 +- opentelemetry-sdk/src/metrics/error.rs | 40 ++++++++++++ opentelemetry-sdk/src/metrics/exporter.rs | 2 +- .../src/metrics/manual_reader.rs | 7 +- opentelemetry-sdk/src/metrics/meter.rs | 5 +- .../src/metrics/meter_provider.rs | 3 +- opentelemetry-sdk/src/metrics/mod.rs | 2 + .../src/metrics/periodic_reader.rs | 7 +- opentelemetry-sdk/src/metrics/pipeline.rs | 6 +- opentelemetry-sdk/src/metrics/reader.rs | 2 +- opentelemetry-sdk/src/metrics/view.rs | 2 +- opentelemetry/src/common.rs | 6 -- opentelemetry/src/global/mod.rs | 2 - opentelemetry/src/lib.rs | 3 +- opentelemetry/src/logs/mod.rs | 64 ------------------- opentelemetry/src/metrics/mod.rs | 40 +----------- opentelemetry/src/trace/mod.rs | 10 ++- 25 files changed, 148 insertions(+), 150 deletions(-) rename opentelemetry/src/global/error_handler.rs => opentelemetry-sdk/src/error.rs (92%) create mode 100644 opentelemetry-sdk/src/logs/error.rs create mode 100644 opentelemetry-sdk/src/metrics/error.rs diff --git a/opentelemetry/src/global/error_handler.rs b/opentelemetry-sdk/src/error.rs similarity index 92% rename from opentelemetry/src/global/error_handler.rs rename to opentelemetry-sdk/src/error.rs index 76ad4160b8..7c8dde3b1a 100644 --- a/opentelemetry/src/global/error_handler.rs +++ b/opentelemetry-sdk/src/error.rs @@ -1,13 +1,12 @@ use std::sync::PoisonError; -use std::sync::RwLock; #[cfg(feature = "logs")] use crate::logs::LogError; #[cfg(feature = "metrics")] use crate::metrics::MetricError; -use crate::propagation::PropagationError; +use opentelemetry::propagation::PropagationError; #[cfg(feature = "trace")] -use crate::trace::TraceError; +use opentelemetry::trace::TraceError; /// Wrapper for error from both tracing and metrics part of open telemetry. #[derive(thiserror::Error, Debug)] diff --git a/opentelemetry-sdk/src/export/logs/mod.rs b/opentelemetry-sdk/src/export/logs/mod.rs index 2656544ce0..098c6b8427 100644 --- a/opentelemetry-sdk/src/export/logs/mod.rs +++ b/opentelemetry-sdk/src/export/logs/mod.rs @@ -1,10 +1,10 @@ //! Log exporters use crate::logs::LogRecord; +use crate::logs::{LogError, LogResult}; use crate::Resource; use async_trait::async_trait; #[cfg(feature = "logs_level_enabled")] use opentelemetry::logs::Severity; -use opentelemetry::logs::{LogError, LogResult}; use opentelemetry::InstrumentationScope; use std::fmt::Debug; diff --git a/opentelemetry-sdk/src/export/mod.rs b/opentelemetry-sdk/src/export/mod.rs index c59a7028a5..7069d864d0 100644 --- a/opentelemetry-sdk/src/export/mod.rs +++ b/opentelemetry-sdk/src/export/mod.rs @@ -8,4 +8,8 @@ pub mod logs; #[cfg_attr(docsrs, doc(cfg(feature = "trace")))] pub mod trace; -pub use opentelemetry::ExportError; +/// Marker trait for errors returned by exporters +pub trait ExportError: std::error::Error + Send + Sync + 'static { + /// The name of exporter that returned this error + fn exporter_name(&self) -> &'static str; +} diff --git a/opentelemetry-sdk/src/lib.rs b/opentelemetry-sdk/src/lib.rs index 273cb183c8..6f351c2459 100644 --- a/opentelemetry-sdk/src/lib.rs +++ b/opentelemetry-sdk/src/lib.rs @@ -148,3 +148,5 @@ pub mod util; #[doc(inline)] pub use resource::Resource; + +pub mod error; diff --git a/opentelemetry-sdk/src/logs/error.rs b/opentelemetry-sdk/src/logs/error.rs new file mode 100644 index 0000000000..1cbcd29e2e --- /dev/null +++ b/opentelemetry-sdk/src/logs/error.rs @@ -0,0 +1,63 @@ +use crate::export::ExportError; + +use std::{sync::PoisonError, time::Duration}; +use thiserror::Error; + +/// Describe the result of operations in log SDK. +pub type LogResult = Result; + +#[derive(Error, Debug)] +#[non_exhaustive] +/// Errors returned by the log SDK. +pub enum LogError { + /// Export failed with the error returned by the exporter. + #[error("Exporter {} encountered the following errors: {0}", .0.exporter_name())] + ExportFailed(Box), + + /// Export failed to finish after certain period and processor stopped the export. + #[error("Exporter timed out after {} seconds", .0.as_secs())] + ExportTimedOut(Duration), + + /// Processor is already shutdown + #[error("{0} already shutdown")] + AlreadyShutdown(String), + + /// Mutex lock poisoning + #[error("mutex lock poisioning for {0}")] + MutexPoisoned(String), + + /// Other errors propagated from log SDK that weren't covered above. + #[error(transparent)] + Other(#[from] Box), +} + +impl From for LogError +where + T: ExportError, +{ + fn from(err: T) -> Self { + LogError::ExportFailed(Box::new(err)) + } +} + +impl From for LogError { + fn from(err_msg: String) -> Self { + LogError::Other(Box::new(Custom(err_msg))) + } +} + +impl From<&'static str> for LogError { + fn from(err_msg: &'static str) -> Self { + LogError::Other(Box::new(Custom(err_msg.into()))) + } +} + +impl From> for LogError { + fn from(err: PoisonError) -> Self { + LogError::Other(err.to_string().into()) + } +} +/// Wrap type for string +#[derive(Error, Debug)] +#[error("{0}")] +struct Custom(String); diff --git a/opentelemetry-sdk/src/logs/log_emitter.rs b/opentelemetry-sdk/src/logs/log_emitter.rs index 7bc9026d35..0980ad406c 100644 --- a/opentelemetry-sdk/src/logs/log_emitter.rs +++ b/opentelemetry-sdk/src/logs/log_emitter.rs @@ -1,11 +1,7 @@ use super::{BatchLogProcessor, LogProcessor, LogRecord, SimpleLogProcessor, TraceContext}; use crate::{export::logs::LogExporter, runtime::RuntimeChannel, Resource}; -use opentelemetry::{ - logs::{LogError, LogResult}, - otel_debug, - trace::TraceContextExt, - Context, InstrumentationScope, -}; +use crate::{logs::LogError, logs::LogResult}; +use opentelemetry::{otel_debug, trace::TraceContextExt, Context, InstrumentationScope}; #[cfg(feature = "logs_level_enabled")] use opentelemetry::logs::Severity; diff --git a/opentelemetry-sdk/src/logs/log_processor.rs b/opentelemetry-sdk/src/logs/log_processor.rs index fa5308159f..fd35be4f14 100644 --- a/opentelemetry-sdk/src/logs/log_processor.rs +++ b/opentelemetry-sdk/src/logs/log_processor.rs @@ -1,6 +1,6 @@ use crate::{ export::logs::{ExportResult, LogBatch, LogExporter}, - logs::LogRecord, + logs::{LogError, LogRecord, LogResult}, runtime::{RuntimeChannel, TrySend}, Resource, }; @@ -11,10 +11,7 @@ use futures_util::{ }; #[cfg(feature = "logs_level_enabled")] use opentelemetry::logs::Severity; -use opentelemetry::{ - logs::{LogError, LogResult}, - otel_debug, otel_error, otel_warn, InstrumentationScope, -}; +use opentelemetry::{otel_debug, otel_error, otel_warn, InstrumentationScope}; use std::sync::atomic::AtomicBool; use std::{cmp::min, env, sync::Mutex}; diff --git a/opentelemetry-sdk/src/logs/mod.rs b/opentelemetry-sdk/src/logs/mod.rs index c4dd5ec44d..b72cb906da 100644 --- a/opentelemetry-sdk/src/logs/mod.rs +++ b/opentelemetry-sdk/src/logs/mod.rs @@ -1,8 +1,10 @@ //! # OpenTelemetry Log SDK +mod error; mod log_emitter; mod log_processor; pub(crate) mod record; +pub use error::{LogError, LogResult}; pub use log_emitter::{Builder, Logger, LoggerProvider}; pub use log_processor::{ BatchConfig, BatchConfigBuilder, BatchLogProcessor, BatchLogProcessorBuilder, LogProcessor, diff --git a/opentelemetry-sdk/src/metrics/aggregation.rs b/opentelemetry-sdk/src/metrics/aggregation.rs index 6ccd564870..7945492c23 100644 --- a/opentelemetry-sdk/src/metrics/aggregation.rs +++ b/opentelemetry-sdk/src/metrics/aggregation.rs @@ -1,7 +1,7 @@ use std::fmt; use crate::metrics::internal::{EXPO_MAX_SCALE, EXPO_MIN_SCALE}; -use opentelemetry::metrics::{MetricError, MetricResult}; +use crate::metrics::{MetricError, MetricResult}; /// The way recorded measurements are summarized. #[derive(Clone, Debug, PartialEq)] diff --git a/opentelemetry-sdk/src/metrics/error.rs b/opentelemetry-sdk/src/metrics/error.rs new file mode 100644 index 0000000000..13e0e7b752 --- /dev/null +++ b/opentelemetry-sdk/src/metrics/error.rs @@ -0,0 +1,40 @@ +use std::result; +use std::sync::PoisonError; +use thiserror::Error; + +use crate::export::ExportError; + +/// A specialized `Result` type for metric operations. +pub type MetricResult = result::Result; + +/// Errors returned by the metrics API. +#[derive(Error, Debug)] +#[non_exhaustive] +pub enum MetricError { + /// Other errors not covered by specific cases. + #[error("Metrics error: {0}")] + Other(String), + /// Invalid configuration + #[error("Config error {0}")] + Config(String), + /// Fail to export metrics + #[error("Metrics exporter {} failed with {0}", .0.exporter_name())] + ExportErr(Box), + /// Invalid instrument configuration such invalid instrument name, invalid instrument description, invalid instrument unit, etc. + /// See [spec](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#general-characteristics) + /// for full list of requirements. + #[error("Invalid instrument configuration: {0}")] + InvalidInstrumentConfiguration(&'static str), +} + +impl From for MetricError { + fn from(err: T) -> Self { + MetricError::ExportErr(Box::new(err)) + } +} + +impl From> for MetricError { + fn from(err: PoisonError) -> Self { + MetricError::Other(err.to_string()) + } +} diff --git a/opentelemetry-sdk/src/metrics/exporter.rs b/opentelemetry-sdk/src/metrics/exporter.rs index f30685be76..a4e192c414 100644 --- a/opentelemetry-sdk/src/metrics/exporter.rs +++ b/opentelemetry-sdk/src/metrics/exporter.rs @@ -1,7 +1,7 @@ //! Interfaces for exporting metrics use async_trait::async_trait; -use opentelemetry::metrics::MetricResult; +use crate::metrics::MetricResult; use crate::metrics::data::ResourceMetrics; diff --git a/opentelemetry-sdk/src/metrics/manual_reader.rs b/opentelemetry-sdk/src/metrics/manual_reader.rs index f64c61b91d..21bd2a3976 100644 --- a/opentelemetry-sdk/src/metrics/manual_reader.rs +++ b/opentelemetry-sdk/src/metrics/manual_reader.rs @@ -3,10 +3,9 @@ use std::{ sync::{Mutex, Weak}, }; -use opentelemetry::{ - metrics::{MetricError, MetricResult}, - otel_debug, -}; +use opentelemetry::otel_debug; + +use crate::metrics::{MetricError, MetricResult}; use super::{ data::{ResourceMetrics, Temporality}, diff --git a/opentelemetry-sdk/src/metrics/meter.rs b/opentelemetry-sdk/src/metrics/meter.rs index c552109362..2365b52c52 100644 --- a/opentelemetry-sdk/src/metrics/meter.rs +++ b/opentelemetry-sdk/src/metrics/meter.rs @@ -4,8 +4,8 @@ use std::{borrow::Cow, sync::Arc}; use opentelemetry::{ metrics::{ AsyncInstrumentBuilder, Counter, Gauge, Histogram, HistogramBuilder, InstrumentBuilder, - InstrumentProvider, MetricError, MetricResult, ObservableCounter, ObservableGauge, - ObservableUpDownCounter, UpDownCounter, + InstrumentProvider, ObservableCounter, ObservableGauge, ObservableUpDownCounter, + UpDownCounter, }, otel_error, InstrumentationScope, }; @@ -14,6 +14,7 @@ use crate::metrics::{ instrument::{Instrument, InstrumentKind, Observable, ResolvedMeasures}, internal::{self, Number}, pipeline::{Pipelines, Resolver}, + MetricError, MetricResult, }; use super::noop::NoopSyncInstrument; diff --git a/opentelemetry-sdk/src/metrics/meter_provider.rs b/opentelemetry-sdk/src/metrics/meter_provider.rs index 4c53e8d12e..f63eb110ff 100644 --- a/opentelemetry-sdk/src/metrics/meter_provider.rs +++ b/opentelemetry-sdk/src/metrics/meter_provider.rs @@ -8,10 +8,11 @@ use std::{ }; use opentelemetry::{ - metrics::{Meter, MeterProvider, MetricError, MetricResult}, + metrics::{Meter, MeterProvider}, otel_debug, otel_error, InstrumentationScope, }; +use crate::metrics::{MetricError, MetricResult}; use crate::Resource; use super::{ diff --git a/opentelemetry-sdk/src/metrics/mod.rs b/opentelemetry-sdk/src/metrics/mod.rs index 0e7d46acad..9070f9dfec 100644 --- a/opentelemetry-sdk/src/metrics/mod.rs +++ b/opentelemetry-sdk/src/metrics/mod.rs @@ -41,6 +41,7 @@ pub(crate) mod aggregation; pub mod data; +mod error; pub mod exporter; pub(crate) mod instrument; pub(crate) mod internal; @@ -54,6 +55,7 @@ pub mod reader; pub(crate) mod view; pub use aggregation::*; +pub use error::{MetricError, MetricResult}; pub use instrument::*; pub use manual_reader::*; pub use meter_provider::*; diff --git a/opentelemetry-sdk/src/metrics/periodic_reader.rs b/opentelemetry-sdk/src/metrics/periodic_reader.rs index 03a10a54ee..0239144d1e 100644 --- a/opentelemetry-sdk/src/metrics/periodic_reader.rs +++ b/opentelemetry-sdk/src/metrics/periodic_reader.rs @@ -11,14 +11,11 @@ use futures_util::{ stream::{self, FusedStream}, StreamExt, }; -use opentelemetry::{ - metrics::{MetricError, MetricResult}, - otel_debug, otel_error, -}; +use opentelemetry::{otel_debug, otel_error}; use crate::runtime::Runtime; use crate::{ - metrics::{exporter::PushMetricExporter, reader::SdkProducer}, + metrics::{exporter::PushMetricExporter, reader::SdkProducer, MetricError, MetricResult}, Resource, }; diff --git a/opentelemetry-sdk/src/metrics/pipeline.rs b/opentelemetry-sdk/src/metrics/pipeline.rs index acf4605d13..8da41f38fb 100644 --- a/opentelemetry-sdk/src/metrics/pipeline.rs +++ b/opentelemetry-sdk/src/metrics/pipeline.rs @@ -5,10 +5,7 @@ use std::{ sync::{Arc, Mutex}, }; -use opentelemetry::{ - metrics::{MetricError, MetricResult}, - otel_debug, InstrumentationScope, KeyValue, -}; +use opentelemetry::{otel_debug, InstrumentationScope, KeyValue}; use crate::{ metrics::{ @@ -20,6 +17,7 @@ use crate::{ internal::Number, reader::{MetricReader, SdkProducer}, view::View, + MetricError, MetricResult, }, Resource, }; diff --git a/opentelemetry-sdk/src/metrics/reader.rs b/opentelemetry-sdk/src/metrics/reader.rs index 1a98ffbb03..b700c13230 100644 --- a/opentelemetry-sdk/src/metrics/reader.rs +++ b/opentelemetry-sdk/src/metrics/reader.rs @@ -1,7 +1,7 @@ //! Interfaces for reading and producing metrics use std::{fmt, sync::Weak}; -use opentelemetry::metrics::MetricResult; +use crate::metrics::MetricResult; use super::{ data::{ResourceMetrics, Temporality}, diff --git a/opentelemetry-sdk/src/metrics/view.rs b/opentelemetry-sdk/src/metrics/view.rs index 3913412cb7..b4c4a8a4d5 100644 --- a/opentelemetry-sdk/src/metrics/view.rs +++ b/opentelemetry-sdk/src/metrics/view.rs @@ -1,6 +1,6 @@ use super::instrument::{Instrument, Stream}; +use crate::metrics::{MetricError, MetricResult}; use glob::Pattern; -use opentelemetry::metrics::{MetricError, MetricResult}; fn empty_view(_inst: &Instrument) -> Option { None diff --git a/opentelemetry/src/common.rs b/opentelemetry/src/common.rs index f152826b23..c1600d2f63 100644 --- a/opentelemetry/src/common.rs +++ b/opentelemetry/src/common.rs @@ -399,12 +399,6 @@ impl KeyValue { } } -/// Marker trait for errors returned by exporters -pub trait ExportError: std::error::Error + Send + Sync + 'static { - /// The name of exporter that returned this error - fn exporter_name(&self) -> &'static str; -} - /// Information about a library or crate providing instrumentation. /// /// An instrumentation scope should be named to follow any naming conventions diff --git a/opentelemetry/src/global/mod.rs b/opentelemetry/src/global/mod.rs index 5f27b0e08b..182364a18c 100644 --- a/opentelemetry/src/global/mod.rs +++ b/opentelemetry/src/global/mod.rs @@ -130,7 +130,6 @@ //! [`MeterProvider`]: crate::metrics::MeterProvider //! [`set_meter_provider`]: crate::global::set_meter_provider -mod error_handler; mod internal_logging; #[cfg(feature = "metrics")] mod metrics; @@ -138,7 +137,6 @@ mod metrics; mod propagation; #[cfg(feature = "trace")] mod trace; -pub use error_handler::Error; #[cfg(feature = "metrics")] #[cfg_attr(docsrs, doc(cfg(feature = "metrics")))] diff --git a/opentelemetry/src/lib.rs b/opentelemetry/src/lib.rs index 1c8d07caf7..f760aa1017 100644 --- a/opentelemetry/src/lib.rs +++ b/opentelemetry/src/lib.rs @@ -204,8 +204,7 @@ mod common; pub mod testing; pub use common::{ - Array, ExportError, InstrumentationScope, InstrumentationScopeBuilder, Key, KeyValue, - StringValue, Value, + Array, InstrumentationScope, InstrumentationScopeBuilder, Key, KeyValue, StringValue, Value, }; #[cfg(feature = "metrics")] diff --git a/opentelemetry/src/logs/mod.rs b/opentelemetry/src/logs/mod.rs index 1a27edb2e0..e57684bc0f 100644 --- a/opentelemetry/src/logs/mod.rs +++ b/opentelemetry/src/logs/mod.rs @@ -2,11 +2,6 @@ /// This API is not intended to be called by application developers directly. /// It is provided for logging library authors to build log appenders, that /// bridges existing logging systems with OpenTelemetry. -use crate::ExportError; - -use std::{sync::PoisonError, time::Duration}; -use thiserror::Error; - mod logger; mod noop; mod record; @@ -14,62 +9,3 @@ mod record; pub use logger::{Logger, LoggerProvider}; pub use noop::NoopLoggerProvider; pub use record::{AnyValue, LogRecord, Severity}; - -/// Describe the result of operations in log SDK. -pub type LogResult = Result; - -#[derive(Error, Debug)] -#[non_exhaustive] -/// Errors returned by the log SDK. -pub enum LogError { - /// Export failed with the error returned by the exporter. - #[error("Exporter {} encountered the following errors: {0}", .0.exporter_name())] - ExportFailed(Box), - - /// Export failed to finish after certain period and processor stopped the export. - #[error("Exporter timed out after {} seconds", .0.as_secs())] - ExportTimedOut(Duration), - - /// Processor is already shutdown - #[error("{0} already shutdown")] - AlreadyShutdown(String), - - /// Mutex lock poisoning - #[error("mutex lock poisioning for {0}")] - MutexPoisoned(String), - - /// Other errors propagated from log SDK that weren't covered above. - #[error(transparent)] - Other(#[from] Box), -} - -impl From for LogError -where - T: ExportError, -{ - fn from(err: T) -> Self { - LogError::ExportFailed(Box::new(err)) - } -} - -impl From for LogError { - fn from(err_msg: String) -> Self { - LogError::Other(Box::new(Custom(err_msg))) - } -} - -impl From<&'static str> for LogError { - fn from(err_msg: &'static str) -> Self { - LogError::Other(Box::new(Custom(err_msg.into()))) - } -} - -impl From> for LogError { - fn from(err: PoisonError) -> Self { - LogError::Other(err.to_string().into()) - } -} -/// Wrap type for string -#[derive(Error, Debug)] -#[error("{0}")] -struct Custom(String); diff --git a/opentelemetry/src/metrics/mod.rs b/opentelemetry/src/metrics/mod.rs index 6c3a4381fb..075d5cccbe 100644 --- a/opentelemetry/src/metrics/mod.rs +++ b/opentelemetry/src/metrics/mod.rs @@ -1,16 +1,13 @@ //! # OpenTelemetry Metrics API use std::hash::{Hash, Hasher}; -use std::result; use std::sync::Arc; -use std::sync::PoisonError; -use thiserror::Error; mod instruments; mod meter; pub(crate) mod noop; -use crate::{Array, ExportError, KeyValue, Value}; +use crate::{Array, KeyValue, Value}; pub use instruments::{ counter::{Counter, ObservableCounter}, gauge::{Gauge, ObservableGauge}, @@ -21,41 +18,6 @@ pub use instruments::{ }; pub use meter::{Meter, MeterProvider}; -/// A specialized `Result` type for metric operations. -pub type MetricResult = result::Result; - -/// Errors returned by the metrics API. -#[derive(Error, Debug)] -#[non_exhaustive] -pub enum MetricError { - /// Other errors not covered by specific cases. - #[error("Metrics error: {0}")] - Other(String), - /// Invalid configuration - #[error("Config error {0}")] - Config(String), - /// Fail to export metrics - #[error("Metrics exporter {} failed with {0}", .0.exporter_name())] - ExportErr(Box), - /// Invalid instrument configuration such invalid instrument name, invalid instrument description, invalid instrument unit, etc. - /// See [spec](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#general-characteristics) - /// for full list of requirements. - #[error("Invalid instrument configuration: {0}")] - InvalidInstrumentConfiguration(&'static str), -} - -impl From for MetricError { - fn from(err: T) -> Self { - MetricError::ExportErr(Box::new(err)) - } -} - -impl From> for MetricError { - fn from(err: PoisonError) -> Self { - MetricError::Other(err.to_string()) - } -} - struct F64Hashable(f64); impl PartialEq for F64Hashable { diff --git a/opentelemetry/src/trace/mod.rs b/opentelemetry/src/trace/mod.rs index 3f0f74e90e..0604c11e35 100644 --- a/opentelemetry/src/trace/mod.rs +++ b/opentelemetry/src/trace/mod.rs @@ -186,9 +186,17 @@ pub use self::{ tracer::{SamplingDecision, SamplingResult, SpanBuilder, Tracer}, tracer_provider::TracerProvider, }; -use crate::{ExportError, KeyValue}; +use crate::KeyValue; use std::sync::PoisonError; +// TODO - Move ExportError and TraceError to opentelemetry-sdk + +/// Marker trait for errors returned by exporters +pub trait ExportError: std::error::Error + Send + Sync + 'static { + /// The name of exporter that returned this error + fn exporter_name(&self) -> &'static str; +} + /// Describe the result of operations in tracing API. pub type TraceResult = Result; From fa9237bc890bcdba6c94bd0c7cb159205e29517e Mon Sep 17 00:00:00 2001 From: Lalit Date: Mon, 4 Nov 2024 22:37:25 -0800 Subject: [PATCH 04/12] fix build --- opentelemetry-appender-tracing/src/layer.rs | 4 ++-- opentelemetry-otlp/src/exporter/http/logs.rs | 2 +- opentelemetry-otlp/src/exporter/http/metrics.rs | 2 +- opentelemetry-otlp/src/exporter/http/mod.rs | 14 ++++++++------ opentelemetry-otlp/src/exporter/tonic/logs.rs | 2 +- opentelemetry-otlp/src/exporter/tonic/metrics.rs | 2 +- opentelemetry-otlp/src/exporter/tonic/mod.rs | 4 ++-- opentelemetry-otlp/src/logs.rs | 6 +++--- opentelemetry-otlp/src/metric.rs | 2 +- opentelemetry-sdk/benches/log.rs | 6 ++---- opentelemetry-sdk/benches/log_exporter.rs | 3 ++- opentelemetry-sdk/benches/log_processor.rs | 4 ++-- opentelemetry-sdk/benches/metric.rs | 6 +++--- opentelemetry-sdk/src/error.rs | 1 + opentelemetry-sdk/src/logs/log_processor.rs | 3 ++- opentelemetry-sdk/src/metrics/aggregation.rs | 2 +- opentelemetry-sdk/src/metrics/meter.rs | 2 +- opentelemetry-sdk/src/metrics/periodic_reader.rs | 3 ++- .../src/testing/logs/in_memory_exporter.rs | 2 +- .../src/testing/metrics/in_memory_exporter.rs | 4 ++-- .../src/testing/metrics/metric_reader.rs | 2 +- .../src/testing/trace/span_exporters.rs | 7 ++----- opentelemetry-stdout/src/logs/exporter.rs | 2 +- opentelemetry-stdout/src/metrics/exporter.rs | 2 +- opentelemetry/src/global/mod.rs | 1 - stress/src/logs.rs | 4 ++-- 26 files changed, 46 insertions(+), 46 deletions(-) diff --git a/opentelemetry-appender-tracing/src/layer.rs b/opentelemetry-appender-tracing/src/layer.rs index 6b07a8a72d..145bb66bb1 100644 --- a/opentelemetry-appender-tracing/src/layer.rs +++ b/opentelemetry-appender-tracing/src/layer.rs @@ -210,12 +210,12 @@ const fn severity_of_level(level: &Level) -> Severity { mod tests { use crate::layer; use async_trait::async_trait; - use opentelemetry::logs::{LogResult, Severity}; + use opentelemetry::logs::Severity; use opentelemetry::trace::TracerProvider as _; use opentelemetry::trace::{TraceContextExt, TraceFlags, Tracer}; use opentelemetry::{logs::AnyValue, Key}; use opentelemetry_sdk::export::logs::{LogBatch, LogExporter}; - use opentelemetry_sdk::logs::{LogRecord, LoggerProvider}; + use opentelemetry_sdk::logs::{LogRecord, LogResult, LoggerProvider}; use opentelemetry_sdk::testing::logs::InMemoryLogExporter; use opentelemetry_sdk::trace; use opentelemetry_sdk::trace::{Sampler, TracerProvider}; diff --git a/opentelemetry-otlp/src/exporter/http/logs.rs b/opentelemetry-otlp/src/exporter/http/logs.rs index db1932868b..985edc96ee 100644 --- a/opentelemetry-otlp/src/exporter/http/logs.rs +++ b/opentelemetry-otlp/src/exporter/http/logs.rs @@ -2,8 +2,8 @@ use std::sync::Arc; use async_trait::async_trait; use http::{header::CONTENT_TYPE, Method}; -use opentelemetry::logs::{LogError, LogResult}; use opentelemetry_sdk::export::logs::{LogBatch, LogExporter}; +use opentelemetry_sdk::logs::{LogError, LogResult}; use super::OtlpHttpClient; diff --git a/opentelemetry-otlp/src/exporter/http/metrics.rs b/opentelemetry-otlp/src/exporter/http/metrics.rs index b047cd4f32..5ba84b30e6 100644 --- a/opentelemetry-otlp/src/exporter/http/metrics.rs +++ b/opentelemetry-otlp/src/exporter/http/metrics.rs @@ -2,8 +2,8 @@ use std::sync::Arc; use async_trait::async_trait; use http::{header::CONTENT_TYPE, Method}; -use opentelemetry::metrics::{MetricError, MetricResult}; use opentelemetry_sdk::metrics::data::ResourceMetrics; +use opentelemetry_sdk::metrics::{MetricError, MetricResult}; use crate::{metric::MetricsClient, Error}; diff --git a/opentelemetry-otlp/src/exporter/http/mod.rs b/opentelemetry-otlp/src/exporter/http/mod.rs index 154871887b..1b18686a3e 100644 --- a/opentelemetry-otlp/src/exporter/http/mod.rs +++ b/opentelemetry-otlp/src/exporter/http/mod.rs @@ -223,7 +223,7 @@ impl HttpExporterBuilder { /// Create a log exporter with the current configuration #[cfg(feature = "logs")] - pub fn build_log_exporter(mut self) -> opentelemetry::logs::LogResult { + pub fn build_log_exporter(mut self) -> opentelemetry_sdk::logs::LogResult { use crate::{ OTEL_EXPORTER_OTLP_LOGS_ENDPOINT, OTEL_EXPORTER_OTLP_LOGS_HEADERS, OTEL_EXPORTER_OTLP_LOGS_TIMEOUT, @@ -244,7 +244,7 @@ impl HttpExporterBuilder { pub fn build_metrics_exporter( mut self, temporality: opentelemetry_sdk::metrics::data::Temporality, - ) -> opentelemetry::metrics::MetricResult { + ) -> opentelemetry_sdk::metrics::MetricResult { use crate::{ OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, OTEL_EXPORTER_OTLP_METRICS_HEADERS, OTEL_EXPORTER_OTLP_METRICS_TIMEOUT, @@ -315,7 +315,7 @@ impl OtlpHttpClient { fn build_logs_export_body( &self, logs: LogBatch<'_>, - ) -> opentelemetry::logs::LogResult<(Vec, &'static str)> { + ) -> opentelemetry_sdk::logs::LogResult<(Vec, &'static str)> { use opentelemetry_proto::tonic::collector::logs::v1::ExportLogsServiceRequest; let resource_logs = group_logs_by_resource_and_scope(logs, &self.resource); let req = ExportLogsServiceRequest { resource_logs }; @@ -324,7 +324,7 @@ impl OtlpHttpClient { #[cfg(feature = "http-json")] Protocol::HttpJson => match serde_json::to_string_pretty(&req) { Ok(json) => Ok((json.into(), "application/json")), - Err(e) => Err(opentelemetry::logs::LogError::from(e.to_string())), + Err(e) => Err(opentelemetry_sdk::logs::LogError::from(e.to_string())), }, _ => Ok((req.encode_to_vec(), "application/x-protobuf")), } @@ -334,7 +334,7 @@ impl OtlpHttpClient { fn build_metrics_export_body( &self, metrics: &mut opentelemetry_sdk::metrics::data::ResourceMetrics, - ) -> opentelemetry::metrics::MetricResult<(Vec, &'static str)> { + ) -> opentelemetry_sdk::metrics::MetricResult<(Vec, &'static str)> { use opentelemetry_proto::tonic::collector::metrics::v1::ExportMetricsServiceRequest; let req: ExportMetricsServiceRequest = (&*metrics).into(); @@ -343,7 +343,9 @@ impl OtlpHttpClient { #[cfg(feature = "http-json")] Protocol::HttpJson => match serde_json::to_string_pretty(&req) { Ok(json) => Ok((json.into(), "application/json")), - Err(e) => Err(opentelemetry::metrics::MetricError::Other(e.to_string())), + Err(e) => Err(opentelemetry_sdk::metrics::MetricError::Other( + e.to_string(), + )), }, _ => Ok((req.encode_to_vec(), "application/x-protobuf")), } diff --git a/opentelemetry-otlp/src/exporter/tonic/logs.rs b/opentelemetry-otlp/src/exporter/tonic/logs.rs index bf9b6c9ed3..149c4b51f0 100644 --- a/opentelemetry-otlp/src/exporter/tonic/logs.rs +++ b/opentelemetry-otlp/src/exporter/tonic/logs.rs @@ -1,10 +1,10 @@ use async_trait::async_trait; use core::fmt; -use opentelemetry::logs::{LogError, LogResult}; use opentelemetry_proto::tonic::collector::logs::v1::{ logs_service_client::LogsServiceClient, ExportLogsServiceRequest, }; use opentelemetry_sdk::export::logs::{LogBatch, LogExporter}; +use opentelemetry_sdk::logs::{LogError, LogResult}; use tonic::{codegen::CompressionEncoding, service::Interceptor, transport::Channel, Request}; use opentelemetry_proto::transform::logs::tonic::group_logs_by_resource_and_scope; diff --git a/opentelemetry-otlp/src/exporter/tonic/metrics.rs b/opentelemetry-otlp/src/exporter/tonic/metrics.rs index b8a59858eb..4159222cd5 100644 --- a/opentelemetry-otlp/src/exporter/tonic/metrics.rs +++ b/opentelemetry-otlp/src/exporter/tonic/metrics.rs @@ -2,11 +2,11 @@ use core::fmt; use std::sync::Mutex; use async_trait::async_trait; -use opentelemetry::metrics::{MetricError, MetricResult}; use opentelemetry_proto::tonic::collector::metrics::v1::{ metrics_service_client::MetricsServiceClient, ExportMetricsServiceRequest, }; use opentelemetry_sdk::metrics::data::ResourceMetrics; +use opentelemetry_sdk::metrics::{MetricError, MetricResult}; use tonic::{codegen::CompressionEncoding, service::Interceptor, transport::Channel, Request}; use super::BoxInterceptor; diff --git a/opentelemetry-otlp/src/exporter/tonic/mod.rs b/opentelemetry-otlp/src/exporter/tonic/mod.rs index 7089ca045a..e55d13f526 100644 --- a/opentelemetry-otlp/src/exporter/tonic/mod.rs +++ b/opentelemetry-otlp/src/exporter/tonic/mod.rs @@ -254,7 +254,7 @@ impl TonicExporterBuilder { #[cfg(feature = "logs")] pub(crate) fn build_log_exporter( self, - ) -> Result { + ) -> Result { use crate::exporter::tonic::logs::TonicLogsClient; let (channel, interceptor, compression) = self.build_channel( @@ -274,7 +274,7 @@ impl TonicExporterBuilder { pub(crate) fn build_metrics_exporter( self, temporality: opentelemetry_sdk::metrics::data::Temporality, - ) -> opentelemetry::metrics::MetricResult { + ) -> opentelemetry_sdk::metrics::MetricResult { use crate::MetricExporter; use metrics::TonicMetricsClient; diff --git a/opentelemetry-otlp/src/logs.rs b/opentelemetry-otlp/src/logs.rs index 42727a8d74..a0c09ab28d 100644 --- a/opentelemetry-otlp/src/logs.rs +++ b/opentelemetry-otlp/src/logs.rs @@ -5,7 +5,7 @@ use async_trait::async_trait; use std::fmt::Debug; -use opentelemetry::logs::LogResult; +use opentelemetry_sdk::logs::LogResult; use opentelemetry_sdk::export::logs::LogBatch; @@ -62,14 +62,14 @@ impl LogExporterBuilder { #[cfg(feature = "grpc-tonic")] impl LogExporterBuilder { - pub fn build(self) -> Result { + pub fn build(self) -> Result { self.client.0.build_log_exporter() } } #[cfg(any(feature = "http-proto", feature = "http-json"))] impl LogExporterBuilder { - pub fn build(self) -> Result { + pub fn build(self) -> Result { self.client.0.build_log_exporter() } } diff --git a/opentelemetry-otlp/src/metric.rs b/opentelemetry-otlp/src/metric.rs index e2b3408174..3d5f9b981f 100644 --- a/opentelemetry-otlp/src/metric.rs +++ b/opentelemetry-otlp/src/metric.rs @@ -16,7 +16,7 @@ use crate::NoExporterBuilderSet; use async_trait::async_trait; use core::fmt; -use opentelemetry::metrics::MetricResult; +use opentelemetry_sdk::metrics::MetricResult; use opentelemetry_sdk::metrics::{ data::{ResourceMetrics, Temporality}, diff --git a/opentelemetry-sdk/benches/log.rs b/opentelemetry-sdk/benches/log.rs index ca8a76a414..27403aa9d7 100644 --- a/opentelemetry-sdk/benches/log.rs +++ b/opentelemetry-sdk/benches/log.rs @@ -20,13 +20,11 @@ use std::time::SystemTime; use criterion::{criterion_group, criterion_main, Criterion}; -use opentelemetry::logs::{ - AnyValue, LogRecord as _, LogResult, Logger as _, LoggerProvider as _, Severity, -}; +use opentelemetry::logs::{AnyValue, LogRecord as _, Logger as _, LoggerProvider as _, Severity}; use opentelemetry::trace::Tracer; use opentelemetry::trace::TracerProvider as _; use opentelemetry::{InstrumentationScope, Key}; -use opentelemetry_sdk::logs::{LogProcessor, LogRecord, Logger, LoggerProvider}; +use opentelemetry_sdk::logs::{LogProcessor, LogRecord, LogResult, Logger, LoggerProvider}; use opentelemetry_sdk::trace; use opentelemetry_sdk::trace::{Sampler, TracerProvider}; diff --git a/opentelemetry-sdk/benches/log_exporter.rs b/opentelemetry-sdk/benches/log_exporter.rs index c3c027f3e1..c2ecb78ce9 100644 --- a/opentelemetry-sdk/benches/log_exporter.rs +++ b/opentelemetry-sdk/benches/log_exporter.rs @@ -16,7 +16,8 @@ use std::time::SystemTime; use async_trait::async_trait; use criterion::{criterion_group, criterion_main, Criterion}; -use opentelemetry::logs::{LogRecord as _, LogResult, Logger as _, LoggerProvider as _, Severity}; +use opentelemetry::logs::{LogRecord as _, Logger as _, LoggerProvider as _, Severity}; +use opentelemetry_sdk::logs::LogResult; use opentelemetry::InstrumentationScope; use opentelemetry_sdk::export::logs::LogBatch; diff --git a/opentelemetry-sdk/benches/log_processor.rs b/opentelemetry-sdk/benches/log_processor.rs index 03cd71549c..87cd242d0d 100644 --- a/opentelemetry-sdk/benches/log_processor.rs +++ b/opentelemetry-sdk/benches/log_processor.rs @@ -19,10 +19,10 @@ use std::{ use criterion::{criterion_group, criterion_main, Criterion}; use opentelemetry::{ - logs::{LogRecord as _, LogResult, Logger as _, LoggerProvider as _, Severity}, + logs::{LogRecord as _, Logger as _, LoggerProvider as _, Severity}, InstrumentationScope, }; -use opentelemetry_sdk::logs::{LogProcessor, LogRecord, Logger, LoggerProvider}; +use opentelemetry_sdk::logs::{LogProcessor, LogRecord, LogResult, Logger, LoggerProvider}; // Run this benchmark with: // cargo bench --bench log_processor diff --git a/opentelemetry-sdk/benches/metric.rs b/opentelemetry-sdk/benches/metric.rs index 0e36debb50..77de656bb8 100644 --- a/opentelemetry-sdk/benches/metric.rs +++ b/opentelemetry-sdk/benches/metric.rs @@ -3,7 +3,7 @@ use std::sync::{Arc, Weak}; use criterion::{criterion_group, criterion_main, Bencher, Criterion}; use opentelemetry::{ - metrics::{Counter, Histogram, MeterProvider as _, MetricResult}, + metrics::{Counter, Histogram, MeterProvider as _}, Key, KeyValue, }; use opentelemetry_sdk::{ @@ -11,8 +11,8 @@ use opentelemetry_sdk::{ data::{ResourceMetrics, Temporality}, new_view, reader::MetricReader, - Aggregation, Instrument, InstrumentKind, ManualReader, Pipeline, SdkMeterProvider, Stream, - View, + Aggregation, Instrument, InstrumentKind, ManualReader, MetricResult, Pipeline, + SdkMeterProvider, Stream, View, }, Resource, }; diff --git a/opentelemetry-sdk/src/error.rs b/opentelemetry-sdk/src/error.rs index 7c8dde3b1a..115da17b78 100644 --- a/opentelemetry-sdk/src/error.rs +++ b/opentelemetry-sdk/src/error.rs @@ -1,3 +1,4 @@ +//! Wrapper for error from trace, logs and metrics part of open telemetry. use std::sync::PoisonError; #[cfg(feature = "logs")] diff --git a/opentelemetry-sdk/src/logs/log_processor.rs b/opentelemetry-sdk/src/logs/log_processor.rs index fd35be4f14..258c23c811 100644 --- a/opentelemetry-sdk/src/logs/log_processor.rs +++ b/opentelemetry-sdk/src/logs/log_processor.rs @@ -530,6 +530,7 @@ mod tests { }; use crate::export::logs::{LogBatch, LogExporter}; use crate::logs::LogRecord; + use crate::logs::LogResult; use crate::testing::logs::InMemoryLogExporterBuilder; use crate::{ logs::{ @@ -547,7 +548,7 @@ mod tests { use opentelemetry::logs::AnyValue; use opentelemetry::logs::LogRecord as _; use opentelemetry::logs::{Logger, LoggerProvider as _}; - use opentelemetry::{logs::LogResult, KeyValue}; + use opentelemetry::KeyValue; use opentelemetry::{InstrumentationScope, Key}; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::{Arc, Mutex}; diff --git a/opentelemetry-sdk/src/metrics/aggregation.rs b/opentelemetry-sdk/src/metrics/aggregation.rs index 7945492c23..1788b6b264 100644 --- a/opentelemetry-sdk/src/metrics/aggregation.rs +++ b/opentelemetry-sdk/src/metrics/aggregation.rs @@ -153,7 +153,7 @@ mod tests { internal::{EXPO_MAX_SCALE, EXPO_MIN_SCALE}, Aggregation, }; - use opentelemetry::metrics::{MetricError, MetricResult}; + use crate::metrics::{MetricError, MetricResult}; #[test] fn validate_aggregation() { diff --git a/opentelemetry-sdk/src/metrics/meter.rs b/opentelemetry-sdk/src/metrics/meter.rs index 2365b52c52..f4aa9b9748 100644 --- a/opentelemetry-sdk/src/metrics/meter.rs +++ b/opentelemetry-sdk/src/metrics/meter.rs @@ -634,7 +634,7 @@ where mod tests { use std::borrow::Cow; - use opentelemetry::metrics::MetricError; + use crate::metrics::MetricError; use super::{ validate_instrument_name, validate_instrument_unit, INSTRUMENT_NAME_FIRST_ALPHABETIC, diff --git a/opentelemetry-sdk/src/metrics/periodic_reader.rs b/opentelemetry-sdk/src/metrics/periodic_reader.rs index 0239144d1e..b202366051 100644 --- a/opentelemetry-sdk/src/metrics/periodic_reader.rs +++ b/opentelemetry-sdk/src/metrics/periodic_reader.rs @@ -386,11 +386,12 @@ impl MetricReader for PeriodicReader { #[cfg(all(test, feature = "testing"))] mod tests { use super::PeriodicReader; + use crate::metrics::MetricError; use crate::{ metrics::data::ResourceMetrics, metrics::reader::MetricReader, metrics::SdkMeterProvider, runtime, testing::metrics::InMemoryMetricExporter, Resource, }; - use opentelemetry::metrics::{MeterProvider, MetricError}; + use opentelemetry::metrics::MeterProvider; use std::sync::mpsc; #[test] diff --git a/opentelemetry-sdk/src/testing/logs/in_memory_exporter.rs b/opentelemetry-sdk/src/testing/logs/in_memory_exporter.rs index 7bcbd996af..cac026c663 100644 --- a/opentelemetry-sdk/src/testing/logs/in_memory_exporter.rs +++ b/opentelemetry-sdk/src/testing/logs/in_memory_exporter.rs @@ -1,8 +1,8 @@ use crate::export::logs::{LogBatch, LogExporter}; use crate::logs::LogRecord; +use crate::logs::{LogError, LogResult}; use crate::Resource; use async_trait::async_trait; -use opentelemetry::logs::{LogError, LogResult}; use opentelemetry::InstrumentationScope; use std::borrow::Cow; use std::sync::{Arc, Mutex}; diff --git a/opentelemetry-sdk/src/testing/metrics/in_memory_exporter.rs b/opentelemetry-sdk/src/testing/metrics/in_memory_exporter.rs index d5c8a7494c..223c84fe70 100644 --- a/opentelemetry-sdk/src/testing/metrics/in_memory_exporter.rs +++ b/opentelemetry-sdk/src/testing/metrics/in_memory_exporter.rs @@ -1,9 +1,9 @@ use crate::metrics::data; use crate::metrics::data::{Histogram, Metric, ResourceMetrics, ScopeMetrics, Temporality}; use crate::metrics::exporter::PushMetricExporter; +use crate::metrics::MetricError; +use crate::metrics::MetricResult; use async_trait::async_trait; -use opentelemetry::metrics::MetricError; -use opentelemetry::metrics::MetricResult; use std::collections::VecDeque; use std::fmt; use std::sync::{Arc, Mutex}; diff --git a/opentelemetry-sdk/src/testing/metrics/metric_reader.rs b/opentelemetry-sdk/src/testing/metrics/metric_reader.rs index a3c3cf6f49..96c3c939ba 100644 --- a/opentelemetry-sdk/src/testing/metrics/metric_reader.rs +++ b/opentelemetry-sdk/src/testing/metrics/metric_reader.rs @@ -1,12 +1,12 @@ use std::sync::{Arc, Mutex, Weak}; +use crate::metrics::MetricResult; use crate::metrics::{ data::{ResourceMetrics, Temporality}, pipeline::Pipeline, reader::MetricReader, InstrumentKind, }; -use opentelemetry::metrics::MetricResult; #[derive(Debug, Clone)] pub struct TestMetricReader { diff --git a/opentelemetry-sdk/src/testing/trace/span_exporters.rs b/opentelemetry-sdk/src/testing/trace/span_exporters.rs index f8a0776318..e9996e3fc8 100644 --- a/opentelemetry-sdk/src/testing/trace/span_exporters.rs +++ b/opentelemetry-sdk/src/testing/trace/span_exporters.rs @@ -1,8 +1,5 @@ use crate::{ - export::{ - trace::{ExportResult, SpanData, SpanExporter}, - ExportError, - }, + export::trace::{ExportResult, SpanData, SpanExporter}, trace::{SpanEvents, SpanLinks}, }; use futures_util::future::BoxFuture; @@ -80,7 +77,7 @@ pub struct TestExportError(String); impl std::error::Error for TestExportError {} -impl ExportError for TestExportError { +impl opentelemetry::trace::ExportError for TestExportError { fn exporter_name(&self) -> &'static str { "test" } diff --git a/opentelemetry-stdout/src/logs/exporter.rs b/opentelemetry-stdout/src/logs/exporter.rs index 8a2243df0c..c5edb880bf 100644 --- a/opentelemetry-stdout/src/logs/exporter.rs +++ b/opentelemetry-stdout/src/logs/exporter.rs @@ -1,8 +1,8 @@ use async_trait::async_trait; use chrono::{DateTime, Utc}; use core::fmt; -use opentelemetry::logs::LogResult; use opentelemetry_sdk::export::logs::LogBatch; +use opentelemetry_sdk::logs::LogResult; use opentelemetry_sdk::Resource; use std::sync::atomic; diff --git a/opentelemetry-stdout/src/metrics/exporter.rs b/opentelemetry-stdout/src/metrics/exporter.rs index b2b078a51b..d52cd5939f 100644 --- a/opentelemetry-stdout/src/metrics/exporter.rs +++ b/opentelemetry-stdout/src/metrics/exporter.rs @@ -1,11 +1,11 @@ use async_trait::async_trait; use chrono::{DateTime, Utc}; use core::{f64, fmt}; -use opentelemetry::metrics::{MetricError, MetricResult}; use opentelemetry_sdk::metrics::{ data::{self, ScopeMetrics, Temporality}, exporter::PushMetricExporter, }; +use opentelemetry_sdk::metrics::{MetricError, MetricResult}; use std::fmt::Debug; use std::sync::atomic; diff --git a/opentelemetry/src/global/mod.rs b/opentelemetry/src/global/mod.rs index 4bbe0ac66b..182364a18c 100644 --- a/opentelemetry/src/global/mod.rs +++ b/opentelemetry/src/global/mod.rs @@ -137,7 +137,6 @@ mod metrics; mod propagation; #[cfg(feature = "trace")] mod trace; -pub use error_handler::Error; #[cfg(feature = "metrics")] #[cfg_attr(docsrs, doc(cfg(feature = "metrics")))] diff --git a/stress/src/logs.rs b/stress/src/logs.rs index 17fcf2833e..1ede37b1ee 100644 --- a/stress/src/logs.rs +++ b/stress/src/logs.rs @@ -28,11 +28,11 @@ impl LogProcessor for NoOpLogProcessor { ) { } - fn force_flush(&self) -> opentelemetry::logs::LogResult<()> { + fn force_flush(&self) -> opentelemetry_sdk::logs::LogResult<()> { Ok(()) } - fn shutdown(&self) -> opentelemetry::logs::LogResult<()> { + fn shutdown(&self) -> opentelemetry_sdk::logs::LogResult<()> { Ok(()) } } From f2b015634f5b228e86e84f18f82663fdd2601ebc Mon Sep 17 00:00:00 2001 From: Lalit Date: Mon, 4 Nov 2024 22:48:15 -0800 Subject: [PATCH 05/12] build error --- examples/self-diagnostics/src/main.rs | 6 +----- opentelemetry-otlp/examples/basic-otlp-http/src/main.rs | 5 ++--- opentelemetry-otlp/examples/basic-otlp/src/main.rs | 4 ++-- opentelemetry-otlp/src/lib.rs | 6 ++++++ opentelemetry-otlp/tests/integration_test/tests/logs.rs | 2 +- opentelemetry-zipkin/src/exporter/mod.rs | 6 ++++++ 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/examples/self-diagnostics/src/main.rs b/examples/self-diagnostics/src/main.rs index 6a4ebe94fc..63ed117a33 100644 --- a/examples/self-diagnostics/src/main.rs +++ b/examples/self-diagnostics/src/main.rs @@ -1,4 +1,4 @@ -use opentelemetry::global::{self, Error as OtelError}; +use opentelemetry::global; use opentelemetry::KeyValue; use opentelemetry_appender_tracing::layer; use opentelemetry_otlp::{LogExporter, MetricExporter, WithExportConfig}; @@ -7,10 +7,6 @@ use tracing_subscriber::prelude::*; use std::error::Error; -use once_cell::sync::Lazy; -use std::collections::HashSet; -use std::sync::{Arc, Mutex}; - use std::sync::mpsc::channel; fn init_logger_provider() -> opentelemetry_sdk::logs::LoggerProvider { diff --git a/opentelemetry-otlp/examples/basic-otlp-http/src/main.rs b/opentelemetry-otlp/examples/basic-otlp-http/src/main.rs index c67d6b21c5..10365606f0 100644 --- a/opentelemetry-otlp/examples/basic-otlp-http/src/main.rs +++ b/opentelemetry-otlp/examples/basic-otlp-http/src/main.rs @@ -2,7 +2,6 @@ use once_cell::sync::Lazy; use opentelemetry::{ global, - metrics::MetricError, trace::{TraceContextExt, TraceError, Tracer}, InstrumentationScope, KeyValue, }; @@ -11,7 +10,7 @@ use opentelemetry_otlp::WithExportConfig; use opentelemetry_otlp::{LogExporter, MetricExporter, Protocol, SpanExporter}; use opentelemetry_sdk::{ logs::LoggerProvider, - metrics::{PeriodicReader, SdkMeterProvider}, + metrics::{MetricError, PeriodicReader, SdkMeterProvider}, runtime, trace::{self as sdktrace, Config, TracerProvider}, }; @@ -31,7 +30,7 @@ static RESOURCE: Lazy = Lazy::new(|| { )]) }); -fn init_logs() -> Result { +fn init_logs() -> Result { let exporter = LogExporter::builder() .with_http() .with_endpoint("http://localhost:4318/v1/logs") diff --git a/opentelemetry-otlp/examples/basic-otlp/src/main.rs b/opentelemetry-otlp/examples/basic-otlp/src/main.rs index 0f99248bfd..96242458a3 100644 --- a/opentelemetry-otlp/examples/basic-otlp/src/main.rs +++ b/opentelemetry-otlp/examples/basic-otlp/src/main.rs @@ -1,12 +1,12 @@ use once_cell::sync::Lazy; -use opentelemetry::logs::LogError; -use opentelemetry::metrics::MetricError; use opentelemetry::trace::{TraceContextExt, TraceError, Tracer}; use opentelemetry::KeyValue; use opentelemetry::{global, InstrumentationScope}; use opentelemetry_appender_tracing::layer::OpenTelemetryTracingBridge; use opentelemetry_otlp::{LogExporter, MetricExporter, SpanExporter, WithExportConfig}; +use opentelemetry_sdk::logs::LogError; use opentelemetry_sdk::logs::LoggerProvider; +use opentelemetry_sdk::metrics::MetricError; use opentelemetry_sdk::metrics::{PeriodicReader, SdkMeterProvider}; use opentelemetry_sdk::trace::Config; use opentelemetry_sdk::{runtime, trace as sdktrace, Resource}; diff --git a/opentelemetry-otlp/src/lib.rs b/opentelemetry-otlp/src/lib.rs index 4429f6fda9..c8d7c0308a 100644 --- a/opentelemetry-otlp/src/lib.rs +++ b/opentelemetry-otlp/src/lib.rs @@ -391,6 +391,12 @@ impl ExportError for Error { } } +impl opentelemetry::trace::ExportError for Error { + fn exporter_name(&self) -> &'static str { + "otlp" + } +} + /// The communication protocol to use when exporting data. #[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, Copy, Debug, Eq, PartialEq)] diff --git a/opentelemetry-otlp/tests/integration_test/tests/logs.rs b/opentelemetry-otlp/tests/integration_test/tests/logs.rs index 4e437bb069..c06e7e41ac 100644 --- a/opentelemetry-otlp/tests/integration_test/tests/logs.rs +++ b/opentelemetry-otlp/tests/integration_test/tests/logs.rs @@ -2,10 +2,10 @@ use integration_test_runner::logs_asserter::{read_logs_from_json, LogsAsserter}; use log::{info, Level}; -use opentelemetry::logs::LogError; use opentelemetry::KeyValue; use opentelemetry_appender_log::OpenTelemetryLogBridge; use opentelemetry_otlp::{LogExporter, WithExportConfig}; +use opentelemetry_sdk::logs::LogError; use opentelemetry_sdk::logs::LoggerProvider; use opentelemetry_sdk::{logs as sdklogs, runtime, Resource}; use std::error::Error; diff --git a/opentelemetry-zipkin/src/exporter/mod.rs b/opentelemetry-zipkin/src/exporter/mod.rs index e7466c6a2d..1ddd6c2b5b 100644 --- a/opentelemetry-zipkin/src/exporter/mod.rs +++ b/opentelemetry-zipkin/src/exporter/mod.rs @@ -252,3 +252,9 @@ impl ExportError for Error { "zipkin" } } + +impl opentelemetry::trace::ExportError for Error { + fn exporter_name(&self) -> &'static str { + "zipkin" + } +} From 139ed9b639450203322e90b4d5cdad8474252cee Mon Sep 17 00:00:00 2001 From: Lalit Date: Mon, 4 Nov 2024 22:51:31 -0800 Subject: [PATCH 06/12] build fix - continue --- opentelemetry-appender-tracing/benches/logs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentelemetry-appender-tracing/benches/logs.rs b/opentelemetry-appender-tracing/benches/logs.rs index 0237e4a769..0f6023f19b 100644 --- a/opentelemetry-appender-tracing/benches/logs.rs +++ b/opentelemetry-appender-tracing/benches/logs.rs @@ -15,10 +15,10 @@ use async_trait::async_trait; use criterion::{criterion_group, criterion_main, Criterion}; -use opentelemetry::logs::LogResult; use opentelemetry::{InstrumentationScope, KeyValue}; use opentelemetry_appender_tracing::layer as tracing_layer; use opentelemetry_sdk::export::logs::{LogBatch, LogExporter}; +use opentelemetry_sdk::logs::LogResult; use opentelemetry_sdk::logs::{LogProcessor, LogRecord, LoggerProvider}; use opentelemetry_sdk::Resource; use pprof::criterion::{Output, PProfProfiler}; From 11e6acbf743b9d3d80ae630d911ce929e1352681 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Tue, 5 Nov 2024 14:59:23 -0800 Subject: [PATCH 07/12] changeloG --- opentelemetry-sdk/CHANGELOG.md | 12 ++++++++++++ opentelemetry/CHANGELOG.md | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/opentelemetry-sdk/CHANGELOG.md b/opentelemetry-sdk/CHANGELOG.md index 96967fe421..812fe80672 100644 --- a/opentelemetry-sdk/CHANGELOG.md +++ b/opentelemetry-sdk/CHANGELOG.md @@ -34,6 +34,18 @@ - Pin url version to `2.5.2`. The higher version breaks the build refer: [servo/rust-url#992.](https://github.com/servo/rust-url/issues/992) The `url` crate is used when `jaeger_remote_sampler` feature is enabled. +- **BREAKING**: [#2266](https://github.com/open-telemetry/opentelemetry-rust/pull/2266) + - Moved `ExportError` trait from `opentelemetry::ExportError` to `opentelemetry_sdk::export::ExportError` + - Moved `LogError` enum from `opentelemetry::logs::LogError` to `opentelemetry_sdk::logs::LogError` + - Moved `LogResult` type alias from `opentelemetry::logs::LogResult` to `opentelemetry_sdk::logs::LogResult` + - Renamed `opentelemetry::metrics::Result` type alias to `opentelemetry::metrics::MetricResult` + - Renamed `opentelemetry::metrics::MetricsError` enum to `opentelemetry::metrics::MetricError` + - Moved `MetricError` enum from `opentelemetry::metrics::MetricError` to `opentelemetry_sdk::metrics::MetricError` + - Moved `MetricResult` type alias from `opentelemetry::metrics::MetricResult` to `opentelemetry_sdk::metrics::MetricResult` + + - Users calling public APIs that return these constructs (e.g, LoggerProvider::shutdown(), MeterProvider::force_flush()) should now import them from the SDK instead of the API. + - Developers creating custom exporters should ensure they import these constructs from the SDK, not the API. + ## v0.26.0 Released 2024-Sep-30 diff --git a/opentelemetry/CHANGELOG.md b/opentelemetry/CHANGELOG.md index 2b181cc8ad..f5c614f031 100644 --- a/opentelemetry/CHANGELOG.md +++ b/opentelemetry/CHANGELOG.md @@ -39,6 +39,17 @@ let counter = meter.u64_counter("my_counter").build(); - The default behavior of `global::handle_error` was to log the error using `eprintln!`. With otel macro, the internal logs get emitted via `tracing` macros of matching severity. Users now need to configure the `tracing` layer to capture these logs. - Refer to this PR description for migration guide. Also refer to [self-diagnostics](https://github.com/open-telemetry/opentelemetry-rust/tree/main/examples/self-diagnostics) example on how to configure the tracing layer for internal logs. +- [#2266](https://github.com/open-telemetry/opentelemetry-rust/pull/2266) + - Moved `ExportError` trait from `opentelemetry::ExportError` to `opentelemetry_sdk::export::ExportError` + - Created new trait `opentelemetry::trace::ExportError` for trace API. This would be eventually be consolidated with ExportError in the SDK. + - Moved `LogError` enum from `opentelemetry::logs::LogError` to `opentelemetry_sdk::logs::LogError` + - Moved `LogResult` type alias from `opentelemetry::logs::LogResult` to `opentelemetry_sdk::logs::LogResult` + - Renamed `opentelemetry::metrics::Result` type alias to `opentelemetry::metrics::MetricResult` + - Renamed `opentelemetry::metrics::MetricsError` enum to `opentelemetry::metrics::MetricError` + - Moved `MetricError` enum from `opentelemetry::metrics::MetricError` to `opentelemetry_sdk::metrics::MetricError` + - Moved `MetricResult` type alias from `opentelemetry::metrics::MetricResult` to `opentelemetry_sdk::metrics::MetricResult` + These change shouldn't directly affect the users of OpenTelemetry crates, as these constructs are used in SDK and Exporters. + ## v0.26.0 Released 2024-Sep-30 From e7e879d0a7cf146847072be540d45c94543adf0b Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Tue, 5 Nov 2024 16:57:26 -0800 Subject: [PATCH 08/12] Update mod.rs --- opentelemetry-sdk/src/export/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentelemetry-sdk/src/export/mod.rs b/opentelemetry-sdk/src/export/mod.rs index 7069d864d0..21dc2b570c 100644 --- a/opentelemetry-sdk/src/export/mod.rs +++ b/opentelemetry-sdk/src/export/mod.rs @@ -8,7 +8,7 @@ pub mod logs; #[cfg_attr(docsrs, doc(cfg(feature = "trace")))] pub mod trace; -/// Marker trait for errors returned by exporters +/// Trait for errors returned by exporters pub trait ExportError: std::error::Error + Send + Sync + 'static { /// The name of exporter that returned this error fn exporter_name(&self) -> &'static str; From 8e2b1ae52cc7437e8cf8c6f9132c57c4f8637bde Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Tue, 5 Nov 2024 16:58:52 -0800 Subject: [PATCH 09/12] Update CHANGELOG.md --- opentelemetry/CHANGELOG.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/opentelemetry/CHANGELOG.md b/opentelemetry/CHANGELOG.md index f5c614f031..43b4d2a1ca 100644 --- a/opentelemetry/CHANGELOG.md +++ b/opentelemetry/CHANGELOG.md @@ -44,11 +44,9 @@ let counter = meter.u64_counter("my_counter").build(); - Created new trait `opentelemetry::trace::ExportError` for trace API. This would be eventually be consolidated with ExportError in the SDK. - Moved `LogError` enum from `opentelemetry::logs::LogError` to `opentelemetry_sdk::logs::LogError` - Moved `LogResult` type alias from `opentelemetry::logs::LogResult` to `opentelemetry_sdk::logs::LogResult` - - Renamed `opentelemetry::metrics::Result` type alias to `opentelemetry::metrics::MetricResult` - - Renamed `opentelemetry::metrics::MetricsError` enum to `opentelemetry::metrics::MetricError` - Moved `MetricError` enum from `opentelemetry::metrics::MetricError` to `opentelemetry_sdk::metrics::MetricError` - Moved `MetricResult` type alias from `opentelemetry::metrics::MetricResult` to `opentelemetry_sdk::metrics::MetricResult` - These change shouldn't directly affect the users of OpenTelemetry crates, as these constructs are used in SDK and Exporters. + These changes shouldn't directly affect the users of OpenTelemetry crates, as these constructs are used in SDK and Exporters. ## v0.26.0 Released 2024-Sep-30 From e64b544d17c2ca08942ea728a98e79ca34f944ef Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Tue, 5 Nov 2024 16:59:41 -0800 Subject: [PATCH 10/12] Update mod.rs --- opentelemetry/src/trace/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentelemetry/src/trace/mod.rs b/opentelemetry/src/trace/mod.rs index 0604c11e35..09443c4b4c 100644 --- a/opentelemetry/src/trace/mod.rs +++ b/opentelemetry/src/trace/mod.rs @@ -191,7 +191,7 @@ use std::sync::PoisonError; // TODO - Move ExportError and TraceError to opentelemetry-sdk -/// Marker trait for errors returned by exporters +/// Trait for errors returned by exporters pub trait ExportError: std::error::Error + Send + Sync + 'static { /// The name of exporter that returned this error fn exporter_name(&self) -> &'static str; From 345ba47832cf17aaccc1ed5a6b83effa666069a4 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Wed, 6 Nov 2024 14:16:03 -0800 Subject: [PATCH 11/12] error from merge conflict --- opentelemetry-otlp/tests/integration_test/tests/logs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentelemetry-otlp/tests/integration_test/tests/logs.rs b/opentelemetry-otlp/tests/integration_test/tests/logs.rs index e19e3aef64..13068d0938 100644 --- a/opentelemetry-otlp/tests/integration_test/tests/logs.rs +++ b/opentelemetry-otlp/tests/integration_test/tests/logs.rs @@ -5,7 +5,7 @@ use log::{info, Level}; use opentelemetry::KeyValue; use opentelemetry_appender_log::OpenTelemetryLogBridge; use opentelemetry_otlp::LogExporter; -use opentelemetry_sdk::logs::LoggerProvider; +use opentelemetry_sdk::logs::{LogError, LoggerProvider}; use opentelemetry_sdk::{logs as sdklogs, runtime, Resource}; use std::error::Error; use std::fs::File; From fa9c724facb9dd9ab9db717e0026c51551d0b86d Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Wed, 6 Nov 2024 14:30:35 -0800 Subject: [PATCH 12/12] update otel changelog --- opentelemetry/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentelemetry/CHANGELOG.md b/opentelemetry/CHANGELOG.md index 2636cb9d03..878a10d80f 100644 --- a/opentelemetry/CHANGELOG.md +++ b/opentelemetry/CHANGELOG.md @@ -48,7 +48,7 @@ let counter = meter.u64_counter("my_counter").build(); - Moved `LogResult` type alias from `opentelemetry::logs::LogResult` to `opentelemetry_sdk::logs::LogResult` - Moved `MetricError` enum from `opentelemetry::metrics::MetricError` to `opentelemetry_sdk::metrics::MetricError` - Moved `MetricResult` type alias from `opentelemetry::metrics::MetricResult` to `opentelemetry_sdk::metrics::MetricResult` - These changes shouldn't directly affect the users of OpenTelemetry crates, as these constructs are used in SDK and Exporters. + These changes shouldn't directly affect the users of OpenTelemetry crate, as these constructs are used in SDK and Exporters. If you are an author of an sdk component/plug-in, like an exporter etc. please use these types from sdk. Refer [CHANGELOG.md](https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-sdk/CHANGELOG.md) for more details, under same version section. ## v0.26.0 Released 2024-Sep-30