Skip to content

[Bug]: Impossible to disable internal-logs if you import opentelemetry_sdk #2972

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

Open
joeshaw opened this issue May 15, 2025 · 1 comment
Open
Labels
A-common Area:common issues that not related to specific pillar bug Something isn't working triage:accepted Has been triaged and accepted.

Comments

@joeshaw
Copy link

joeshaw commented May 15, 2025

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

@joeshaw joeshaw added bug Something isn't working triage:todo Needs to be traiged. labels May 15, 2025
@joeshaw
Copy link
Author

joeshaw commented May 16, 2025

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.

@cijothomas cijothomas added A-common Area:common issues that not related to specific pillar triage:accepted Has been triaged and accepted. and removed triage:todo Needs to be traiged. labels May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-common Area:common issues that not related to specific pillar bug Something isn't working triage:accepted Has been triaged and accepted.
Projects
None yet
Development

No branches or pull requests

2 participants