diff --git a/opentelemetry-http/Cargo.toml b/opentelemetry-http/Cargo.toml index 395e008d1c..6003ff2762 100644 --- a/opentelemetry-http/Cargo.toml +++ b/opentelemetry-http/Cargo.toml @@ -15,7 +15,7 @@ default = ["internal-logs"] hyper = ["dep:http-body-util", "dep:hyper", "dep:hyper-util", "dep:tokio"] reqwest-rustls = ["reqwest", "reqwest/rustls-tls-native-roots"] reqwest-rustls-webpki-roots = ["reqwest", "reqwest/rustls-tls-webpki-roots"] -internal-logs = ["tracing", "opentelemetry/internal-logs"] +internal-logs = ["opentelemetry/internal-logs"] [dependencies] async-trait = { workspace = true } @@ -27,12 +27,6 @@ hyper-util = { workspace = true, features = ["client-legacy", "http1", "http2"], opentelemetry = { version = "0.29", path = "../opentelemetry", features = ["trace"] } reqwest = { workspace = true, features = ["blocking"], optional = true } tokio = { workspace = true, features = ["time"], optional = true } -tracing = {workspace = true, optional = true} - -[package.metadata.cargo-machete] -ignored = [ - "tracing" # needed for `internal-logs` -] [lints] workspace = true diff --git a/opentelemetry-jaeger-propagator/Cargo.toml b/opentelemetry-jaeger-propagator/Cargo.toml index e2534ab9d5..0d15822ead 100644 --- a/opentelemetry-jaeger-propagator/Cargo.toml +++ b/opentelemetry-jaeger-propagator/Cargo.toml @@ -24,19 +24,13 @@ rustdoc-args = ["--cfg", "docsrs"] opentelemetry = { version = "0.29", default-features = false, features = [ "trace", ], path = "../opentelemetry" } -tracing = {workspace = true, optional = true} # optional for opentelemetry internal logging [dev-dependencies] opentelemetry = { features = ["testing"], path = "../opentelemetry" } [features] default = ["internal-logs"] -internal-logs = ["tracing"] - -[package.metadata.cargo-machete] -ignored = [ - "tracing" # needed for `internal-logs` -] +internal-logs = ["opentelemetry/internal-logs"] [lints] workspace = true diff --git a/opentelemetry-proto/Cargo.toml b/opentelemetry-proto/Cargo.toml index 162728ff2e..d4ee2ffc74 100644 --- a/opentelemetry-proto/Cargo.toml +++ b/opentelemetry-proto/Cargo.toml @@ -46,7 +46,7 @@ zpages = ["trace"] testing = ["opentelemetry/testing"] # add ons -internal-logs = ["tracing"] +internal-logs = ["opentelemetry/internal-logs"] with-schemars = ["schemars"] with-serde = ["serde", "hex", "base64"] @@ -58,7 +58,6 @@ opentelemetry_sdk = { version = "0.29", default-features = false, path = "../ope schemars = { workspace = true, optional = true } serde = { workspace = true, optional = true, features = ["serde_derive"] } hex = { workspace = true, optional = true } -tracing = {workspace = true, optional = true} # optional for opentelemetry internal logging base64 = { workspace = true, optional = true } [dev-dependencies] @@ -68,10 +67,5 @@ prost-build = { workspace = true } tempfile = { workspace = true } serde_json = { workspace = true } -[package.metadata.cargo-machete] -ignored = [ - "tracing" # needed for `internal-logs` -] - [lints] workspace = true diff --git a/opentelemetry-sdk/Cargo.toml b/opentelemetry-sdk/Cargo.toml index 603ce8fbfc..fb53687d0b 100644 --- a/opentelemetry-sdk/Cargo.toml +++ b/opentelemetry-sdk/Cargo.toml @@ -26,7 +26,6 @@ url = { workspace = true, optional = true } tokio = { workspace = true, features = ["rt", "time"], optional = true } tokio-stream = { workspace = true, optional = true } http = { workspace = true, optional = true } -tracing = {workspace = true, optional = true} [package.metadata.docs.rs] all-features = true @@ -51,7 +50,7 @@ testing = ["opentelemetry/testing", "trace", "metrics", "logs", "rt-tokio", "rt- experimental_async_runtime = [] rt-tokio = ["tokio", "tokio-stream", "experimental_async_runtime"] rt-tokio-current-thread = ["tokio", "tokio-stream", "experimental_async_runtime"] -internal-logs = ["tracing"] +internal-logs = ["opentelemetry/internal-logs"] experimental_metrics_periodicreader_with_async_runtime = ["metrics", "experimental_async_runtime"] spec_unstable_metrics_views = ["metrics"] experimental_logs_batch_log_processor_with_async_runtime = ["logs", "experimental_async_runtime"] @@ -59,11 +58,6 @@ experimental_logs_concurrent_log_processor = ["logs"] experimental_trace_batch_span_processor_with_async_runtime = ["trace", "experimental_async_runtime"] experimental_metrics_disable_name_validation = ["metrics"] -[package.metadata.cargo-machete] -ignored = [ - "tracing" # needed for `internal-logs` -] - [[bench]] name = "context" harness = false diff --git a/opentelemetry/CHANGELOG.md b/opentelemetry/CHANGELOG.md index c366d2cf39..ea0b8e8f97 100644 --- a/opentelemetry/CHANGELOG.md +++ b/opentelemetry/CHANGELOG.md @@ -23,6 +23,8 @@ These methods allow SDK components, exporters, and processors to temporarily disable telemetry generation during their internal operations, ensuring more predictable and efficient observability pipelines. +- re-export `tracing` for `internal-logs` feature to remove the need of adding `tracing` as a dependency + ## 0.29.0 Released 2025-Mar-21 diff --git a/opentelemetry/src/global/internal_logging.rs b/opentelemetry/src/global/internal_logging.rs index 012a9c98ce..3c6a82bf3c 100644 --- a/opentelemetry/src/global/internal_logging.rs +++ b/opentelemetry/src/global/internal_logging.rs @@ -26,7 +26,7 @@ macro_rules! otel_info { (name: $name:expr $(,)?) => { #[cfg(feature = "internal-logs")] { - tracing::info!( name: $name, target: env!("CARGO_PKG_NAME"), name = $name, ""); + $crate::_private::info!( name: $name, target: env!("CARGO_PKG_NAME"), name = $name, ""); } #[cfg(test)] @@ -42,7 +42,7 @@ macro_rules! otel_info { (name: $name:expr, $($key:ident = $value:expr),+ $(,)?) => { #[cfg(feature = "internal-logs")] { - tracing::info!(name: $name, target: env!("CARGO_PKG_NAME"), name = $name, $($key = $value),+, ""); + $crate::_private::info!(name: $name, target: env!("CARGO_PKG_NAME"), name = $name, $($key = $value),+, ""); } #[cfg(test)] @@ -77,7 +77,7 @@ macro_rules! otel_warn { (name: $name:expr $(,)?) => { #[cfg(feature = "internal-logs")] { - tracing::warn!(name: $name, target: env!("CARGO_PKG_NAME"), name = $name, ""); + $crate::_private::warn!(name: $name, target: env!("CARGO_PKG_NAME"), name = $name, ""); } #[cfg(test)] @@ -93,7 +93,7 @@ macro_rules! otel_warn { (name: $name:expr, $($key:ident = $value:expr),+ $(,)?) => { #[cfg(feature = "internal-logs")] { - tracing::warn!(name: $name, + $crate::_private::warn!(name: $name, target: env!("CARGO_PKG_NAME"), name = $name, $($key = { @@ -135,7 +135,7 @@ macro_rules! otel_debug { (name: $name:expr $(,)?) => { #[cfg(feature = "internal-logs")] { - tracing::debug!(name: $name, target: env!("CARGO_PKG_NAME"), name = $name, ""); + $crate::_private::debug!(name: $name, target: env!("CARGO_PKG_NAME"), name = $name, ""); } #[cfg(test)] @@ -151,7 +151,7 @@ macro_rules! otel_debug { (name: $name:expr, $($key:ident = $value:expr),+ $(,)?) => { #[cfg(feature = "internal-logs")] { - tracing::debug!(name: $name, target: env!("CARGO_PKG_NAME"), name = $name, $($key = $value),+, ""); + $crate::_private::debug!(name: $name, target: env!("CARGO_PKG_NAME"), name = $name, $($key = $value),+, ""); } #[cfg(test)] @@ -186,7 +186,7 @@ macro_rules! otel_error { (name: $name:expr $(,)?) => { #[cfg(feature = "internal-logs")] { - tracing::error!(name: $name, target: env!("CARGO_PKG_NAME"), name = $name, ""); + $crate::_private::error!(name: $name, target: env!("CARGO_PKG_NAME"), name = $name, ""); } #[cfg(test)] @@ -202,7 +202,7 @@ macro_rules! otel_error { (name: $name:expr, $($key:ident = $value:expr),+ $(,)?) => { #[cfg(feature = "internal-logs")] { - tracing::error!(name: $name, + $crate::_private::error!(name: $name, target: env!("CARGO_PKG_NAME"), name = $name, $($key = { diff --git a/opentelemetry/src/lib.rs b/opentelemetry/src/lib.rs index 8defffb989..ebed7960ea 100644 --- a/opentelemetry/src/lib.rs +++ b/opentelemetry/src/lib.rs @@ -299,3 +299,9 @@ pub mod time { SystemTime::UNIX_EPOCH + std::time::Duration::from_millis(js_sys::Date::now() as u64) } } + +#[doc(hidden)] +pub mod _private { + #[cfg(feature = "internal-logs")] + pub use tracing::{debug, error, info, warn}; // re-export +}