Skip to content

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

Open
@joeshaw

Description

@joeshaw

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-commonArea:common issues that not related to specific pillarbugSomething isn't workingtriage:acceptedHas been triaged and accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions