Skip to content

util/tracing: remove semconv dependency#6549

Open
thaJeztah wants to merge 1 commit intomoby:masterfrom
thaJeztah:drop_semconv
Open

util/tracing: remove semconv dependency#6549
thaJeztah wants to merge 1 commit intomoby:masterfrom
thaJeztah:drop_semconv

Conversation

@thaJeztah
Copy link
Member

Replace semconv imports with local constants for semconv keys.

These attributes are marked Stable in the OpenTelemetry Semantic Conventions and are not expected to change across semver releases:

This avoids pulling in versioned semconv packages solely for stable attribute keys and prevents duplicate semconv versions in the module graph.

// semconv version. It corresponds to [semconv.SchemaURL].
//
// [semconv.SchemaURL]: https://pkg.go.dev/go.opentelemetry.io/otel/semconv/v1.37.0#SchemaURL
const schemaURL = ""
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I could find, it's OK to keep this empty (the GoDoc linked above describes "must be non-empty" but that applies to semconv itself); alternatively we can pin this to a version ("https://opentelemetry.io/schemas/1.37.0" for example), but looks like there's no real benefit?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer that we keep the schema url to be something. This is just mostly so just in case they do change something we're advertising which semconv version we're using.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, makes sense; won't do harm.

This comment was marked as outdated.

@thaJeztah thaJeztah force-pushed the drop_semconv branch 2 times, most recently from 8b67d5f to 272d7af Compare March 3, 2026 12:15
@thaJeztah thaJeztah requested a review from Copilot March 3, 2026 12:15

This comment was marked as outdated.

@thaJeztah thaJeztah force-pushed the drop_semconv branch 2 times, most recently from b27618d to b96c93c Compare March 3, 2026 12:26
@thaJeztah thaJeztah requested a review from Copilot March 3, 2026 12:26

This comment was marked as outdated.

@thaJeztah

This comment was marked as resolved.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the benefit of duplicating these, considering the semconv pkg is vendored anyway?

Copy link
Collaborator

@jsternberg jsternberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with this. We're unlikely to change it and if it means that other projects don't have to vendor useless code or that we vendor less I'm good with it.

Replace semconv imports with local constants for semconv keys.

These attributes are marked Stable in the OpenTelemetry Semantic
Conventions and are not expected to change across semver releases:

- https://opentelemetry.io/docs/specs/semconv/
- https://opentelemetry.io/docs/specs/otel/versioning-and-stability/#semantic-conventions-stability

This avoids pulling in versioned semconv packages solely for stable
attribute keys and prevents duplicate semconv versions in the module
graph.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
Copy link
Member Author

What's the benefit of duplicating these, considering the semconv pkg is vendored anyway?

My motivation was that I started to see us accumulate a trip down memory lane for OTEL "SemConv" versions; it's not a separate module (it's a "versioned" package), so every import of any semconv/vx.y.z will add another copy of that version to vendor/, each 10k+ LOC. While that won't really have an impact on the binary size (we only consume a couple of consts, and there's probably not a lot more in that package), it still means more code-churn.

While previously we had to make sure we'd align because these properties weren't stable yet; they're now stable, so we're effectively importing 10k+ code for 5 strings that will never change.

With this PR, our own imports won't change, and updating OTEL+OTEL/contrib versions (when done at the same time) should more likely see the semconv files to be a lateral move / rename of the files (with only differences between old and new version as diff), instead of "add another copy of these files"). I already did similar PRs in Moby and Containerd, so with a bit of luck the only "versioned" imports will now be from OTEL itself, which will just be updated when we update OTEL dependencies.

For reference; size is not the issue; looking at dockerd (76 kB + 1.1 kB + 419 B) and containerd;

Screenshot 2026-03-13 at 16 00 10 Screenshot 2026-03-13 at 16 19 52

@jsternberg
Copy link
Collaborator

While previously we had to make sure we'd align because these properties weren't stable yet; they're now stable, so we're effectively importing 10k+ code for 5 strings that will never change.

Just for a bit of context on this, the versioned semver packages will never change even if they were unstable or beta. That's what the schema url is meant for is to allow the names to change. At the same time, these specific properties, while they theoretically could change, are unlikely to ever change just due to how ingrained they are and how many people it would inadvertently break.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants