Skip to content

Commit 58d23ab

Browse files
committed
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. [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 <[email protected]> (cherry picked from commit 0d27fce) Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent d65025d commit 58d23ab

10 files changed

Lines changed: 6 additions & 6872 deletions

File tree

pkg/tracing/tracing.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"go.opentelemetry.io/otel"
2626
"go.opentelemetry.io/otel/attribute"
2727
"go.opentelemetry.io/otel/codes"
28-
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
2928
"go.opentelemetry.io/otel/trace"
3029
)
3130

@@ -125,8 +124,11 @@ func Attribute(k string, v any) attribute.KeyValue {
125124
return keyValue(k, v)
126125
}
127126

128-
// HTTPStatusCodeAttributes generates attributes of the HTTP namespace as specified by the OpenTelemetry
129-
// specification for a span.
127+
// HTTPStatusCodeAttributes generates HTTP response status code attributes
128+
// as specified by the current OpenTelemetry semantic conventions.
130129
func HTTPStatusCodeAttributes(code int) []attribute.KeyValue {
131-
return []attribute.KeyValue{semconv.HTTPStatusCodeKey.Int(code)}
130+
return []attribute.KeyValue{
131+
attribute.Int("http.response.status_code", code),
132+
attribute.Int("http.status_code", code), // Deprecated: SemConv <= v1.21
133+
}
132134
}

vendor/go.opentelemetry.io/otel/semconv/v1.21.0/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)