[Bug]: Impossible to disable `internal-logs` if you import opentelemetry_sdk
What happened?
A service was spamming local logs with the message:
2025-05-15T18:21:42.793642Z INFO opentelemetry: name="MeterProvider.GlobalSet" Global meter provider is set. Meters can now be created using global::meter() or global::meter_with_scope().
I should be able to suppress this by disabling the internal-logs feature, which is on by default. In my Cargo.toml file, I have under workspace.dependencies:
opentelemetry = { version = "0.27.1", default-features = false, features = ["metrics", "trace"] }
opentelemetry-otlp = { version = "0.27.0", default-features = false, features = ["metrics", "trace", "http-json"] }
opentelemetry-proto = { version = "0.27.0", default-features = false, features = ["metrics", "trace", "gen-tonic-messages", "with-serde"] }
opentelemetry_sdk = { version = "0.27.1", default-features = false, features = ["metrics", "trace"] }
So I would expect this to not be on. However, running cargo tree -e features --no-default-features shows this, which I've trimmed and pruned for readability:
│ │ ├── opentelemetry-otlp feature "http-json"
│ │ │ ├── opentelemetry-otlp v0.27.0
│ │ │ │ ├── opentelemetry-proto v0.27.0
│ │ │ │ │ ├── opentelemetry_sdk v0.27.1
│ │ │ │ │ │ ├── opentelemetry feature "default"
│ │ │ │ │ │ │ ├── opentelemetry v0.27.1 (*)
│ │ │ │ │ │ │ ├── opentelemetry feature "internal-logs"
Looking in the Cargo.toml file for opentelemetry_sdk, we have:
[dependencies]
opentelemetry = { version = "0.29", path = "../opentelemetry/" }
opentelemetry-http = { version = "0.29", path = "../opentelemetry-http", optional = true }
I am not a Cargo expert, but my interpretation of this is that any import of opentelemetry_sdk will require the defaults of opentelemetry and thus internal-logs. (And transitively also for opentelemetry-http, if it is included.)
It seems to me that every dependency of an opentelemetry crate should be default-features = false in all Cargo.toml files across the repository, if you want it to be possible to turn off internal logging.
OpenTelemetry API Version (i.e version of opentelemetry crate)
0.27.1, although it's also true of the current main branch (0.29).
OpenTelemetry SDK Version (i.e version of opentelemetry_sdk crate)
0.27.1, although it's also true of the current main branch (0.29).
What Exporter(s) are you seeing the problem on?
No response
Relevant log output
And FYI, as a workaround I am able to suppress this with
use tracing_subscriber::filter::{LevelFilter, Targets};
let filter = Targets::default()
.with_target("opentelemetry", LevelFilter::OFF)
.with_default(LevelFilter::INFO);
and passing that into the subscriber construction, but it would still be nice to be able to disable it in Cargo so it can be optimized out by the compiler.
https://github.com/open-telemetry/opentelemetry-rust/pull/3085 should take care of this.
Fixed via #3085