Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: re-export tracing for internal-logs #2867

Merged
merged 8 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions opentelemetry-http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,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 }
Expand All @@ -26,12 +26,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
8 changes: 1 addition & 7 deletions opentelemetry-jaeger-propagator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,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
8 changes: 1 addition & 7 deletions opentelemetry-proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ zpages = ["trace"]
testing = ["opentelemetry/testing"]

# add ons
internal-logs = ["tracing"]
internal-logs = []
with-schemars = ["schemars"]
with-serde = ["serde", "hex", "base64"]

Expand All @@ -56,7 +56,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]
Expand All @@ -66,10 +65,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
8 changes: 1 addition & 7 deletions opentelemetry-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,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
Expand All @@ -50,19 +49,14 @@ 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 = []
experimental_metrics_periodicreader_with_async_runtime = ["metrics"]
spec_unstable_metrics_views = ["metrics"]
experimental_logs_batch_log_processor_with_async_runtime = ["logs"]
experimental_logs_concurrent_log_processor = ["logs"]
experimental_trace_batch_span_processor_with_async_runtime = ["trace"]
experimental_metrics_disable_name_validation = ["metrics"]

[package.metadata.cargo-machete]
ignored = [
"tracing" # needed for `internal-logs`
]

[[bench]]
name = "context"
harness = false
Expand Down
2 changes: 2 additions & 0 deletions opentelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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
Expand Down
16 changes: 8 additions & 8 deletions opentelemetry/src/global/internal_logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::tracing::info!( name: $name, target: env!("CARGO_PKG_NAME"), name = $name, "");
}

#[cfg(test)]
Expand All @@ -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::tracing::info!(name: $name, target: env!("CARGO_PKG_NAME"), name = $name, $($key = $value),+, "");
}

#[cfg(test)]
Expand Down Expand Up @@ -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::tracing::warn!(name: $name, target: env!("CARGO_PKG_NAME"), name = $name, "");
}

#[cfg(test)]
Expand All @@ -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::tracing::warn!(name: $name,
target: env!("CARGO_PKG_NAME"),
name = $name,
$($key = {
Expand Down Expand Up @@ -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::tracing::debug!(name: $name, target: env!("CARGO_PKG_NAME"), name = $name, "");
}

#[cfg(test)]
Expand All @@ -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::tracing::debug!(name: $name, target: env!("CARGO_PKG_NAME"), name = $name, $($key = $value),+, "");
}

#[cfg(test)]
Expand Down Expand Up @@ -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::tracing::error!(name: $name, target: env!("CARGO_PKG_NAME"), name = $name, "");
}

#[cfg(test)]
Expand All @@ -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::tracing::error!(name: $name,
target: env!("CARGO_PKG_NAME"),
name = $name,
$($key = {
Expand Down
6 changes: 6 additions & 0 deletions opentelemetry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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; // re-export
}