Skip to content

Conversation

@thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Dec 1, 2025

pkg/tracing: HTTPStatusCodeAttributes: remove use of deprecated SemConv const

The "http.status_code" attribute was deprecated in SemConv v1.21 in favor
of "http.response.status_code", and the HTTPStatusCodeKey const was deprecated
in SemConv v1.22.

The HTTPStatusCodeAttributes utility doesn't appear to be used currently, but
let's update it to use both the old and new variants in case someone still uses
it.

@github-project-automation github-project-automation bot moved this to Needs Triage in Pull Request Review Dec 1, 2025
@thaJeztah thaJeztah changed the title pkg/tracing: update to semconv v1.37.0 pkg/tracing: HTTPStatusCodeAttributes: remove use of deprecated SemConv const Dec 1, 2025
Comment on lines +127 to 129
// HTTPStatusCodeAttributes generates HTTP response status code attributes
// as specified by the current OpenTelemetry semantic conventions.
func HTTPStatusCodeAttributes(code int) []attribute.KeyValue {
Copy link
Member Author

@thaJeztah thaJeztah Dec 1, 2025

Choose a reason for hiding this comment

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

Looks like the only use of this function is in the nydus snapshotter; https://github.com/containerd/nydus-snapshotter/blob/eda72f05cd118853c2ea7a2fc3ce206ce97e31b2/pkg/remote/remotes/docker/resolver.go#L598-L600

Maybe we should consider deprecating it 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

@thaJeztah thaJeztah marked this pull request as ready for review December 1, 2025 16:47
@dosubot dosubot bot added the go Pull requests that update Go code label Dec 1, 2025
Comment on lines +130 to +133
return []attribute.KeyValue{
attribute.Int("http.response.status_code", code),
attribute.Int("http.status_code", code), // Deprecated: SemConv <= v1.21
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if we must keep both, or if we should just swap it for the non-deprecated one.

@thaJeztah thaJeztah added the cherry-pick/2.2.x Change to be cherry picked to release/2.2 branch label Dec 1, 2025
@austinvazquez austinvazquez requested a review from Copilot December 9, 2025 21:55
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

This PR removes the dependency on the deprecated semconv.HTTPStatusCodeKey constant and updates HTTPStatusCodeAttributes to use both the current and deprecated HTTP status code attribute names for backward compatibility.

Key Changes:

  • Removes the deprecated semconv package import
  • Updates HTTPStatusCodeAttributes to return both the new "http.response.status_code" and deprecated "http.status_code" attributes

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

return []attribute.KeyValue{semconv.HTTPStatusCodeKey.Int(code)}
return []attribute.KeyValue{
attribute.Int("http.response.status_code", code),
attribute.Int("http.status_code", code), // Deprecated: SemConv <= v1.21
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The deprecation comment is imprecise. According to the PR description, 'http.status_code' was deprecated in SemConv v1.21, not in versions up to and including v1.21. The comment should read '// Deprecated: SemConv v1.21+' or '// Deprecated: since SemConv v1.21' to accurately reflect when the deprecation occurred.

Suggested change
attribute.Int("http.status_code", code), // Deprecated: SemConv <= v1.21
attribute.Int("http.status_code", code), // Deprecated: since SemConv v1.21

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

The intent, or at least my understanding, was "http.status_code" was semconv <= v1.21.

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, the deprecation is all a bit ambiguous; semconv 1.21 mentions "deprecated", but not in the correct format;

// HTTPStatusCodeKey is the attribute Key conforming to the
// "http.status_code" semantic conventions. It represents the deprecated,
// use `http.response.status_code` instead.

https://github.com/open-telemetry/opentelemetry-go/blob/f0743836e60abb3b1e0e0cf448c7a3f5f7ea83f6/semconv/v1.21.0/attribute_group.go#L106-L108

I tried to find the actual commit that deprecated these, but there wasn't a clear one; the v1.21.0 SemConv files were added with the "deprecated" change already present; idealy v1.21.0 would've been added as a copy of v1.20.0, then changes applied to more easily see what changed, but alas; open-telemetry/opentelemetry-go@830fae8

Copy link
Member Author

Choose a reason for hiding this comment

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

That said, with containerd/nydus-snapshotter#694 merged, I don't think there's any remaining users of this function at all, so perhaps we could even deprecate it and remove in a future release.

Copy link
Member

@austinvazquez austinvazquez left a comment

Choose a reason for hiding this comment

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

LGTM, I'm not versed in open telemetry but from a general perspective it seems low cost to carry both in this fashion. The code reduction is a nice touch. Yet another example where a little copy is better than a little dependency.

@github-project-automation github-project-automation bot moved this from Needs Triage to Review In Progress in Pull Request Review Dec 11, 2025
@dmcgowan dmcgowan added this pull request to the merge queue Dec 11, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 11, 2025
@thaJeztah
Copy link
Member Author

Looks like the merge queue failed; maybe someone can kick it again

@dmcgowan dmcgowan added this pull request to the merge queue Dec 11, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 11, 2025
…nv const

The "http.status_code" attribute was deprecated in [SemConv v1.21] in favor
of "http.response.status_code", and the `HTTPStatusCodeKey` const was deprecated
in [SemConv v1.22].

The `HTTPStatusCodeAttributes` utility doesn't appear to be used currently, but
let's update it to use both the old and new variants in case someone still uses
it.

[SemConv v1.21]: https://github.com/open-telemetry/opentelemetry-go/blob/v1.38.0/semconv/v1.21.0/attribute_group.go#L106-L114
[SemConv v1.22]: https://github.com/open-telemetry/opentelemetry-go/blob/v1.38.0/semconv/v1.22.0/attribute_group.go#L1444-L1452

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

Did a quick rebase to have a fresh run of CI, but if someone could add it back to the merge queue; GitHub has been bad last few days.

@estesp estesp added this pull request to the merge queue Dec 16, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 16, 2025
@estesp estesp added this pull request to the merge queue Dec 16, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 16, 2025
@estesp estesp added this pull request to the merge queue Dec 16, 2025
Merged via the queue into containerd:main with commit 48baa31 Dec 16, 2025
89 of 92 checks passed
@github-project-automation github-project-automation bot moved this from Review In Progress to Done in Pull Request Review Dec 16, 2025
@thaJeztah thaJeztah deleted the bump_semconv branch December 16, 2025 18:03
@austinvazquez austinvazquez added cherry-picked/2.2.x PR commits are cherry-picked into release/2.2 branch and removed cherry-pick/2.2.x Change to be cherry picked to release/2.2 branch labels Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked/2.2.x PR commits are cherry-picked into release/2.2 branch go Pull requests that update Go code size/XXL

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants