Skip to content

Commit b40fdf1

Browse files
Aneurysm9MrAlias
andauthored
Move content length out of basic attributes (#1031)
* Move content length out of basic attributes semconv.httpBasicAttributesFromHTTPRequest() was including the request's content length, which is a high-cardinality label. It ended up in metric labels through the use of that function by semconv.HTTPServerMetricAttributesFromHTTPRequest(). * Add CHANGELOG entry Co-authored-by: Tyler Yahn <[email protected]>
1 parent 3780b80 commit b40fdf1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
1212

1313
- Renamed `go.opentelemetry.io/otel/api/standard` package to `go.opentelemetry.io/otel/semconv` to avoid the ambiguous and generic name `standard` and better describe the package as containing OpenTelemetry semantic conventions. (#1016)
1414

15+
### Fixed
16+
17+
- The `semconv.HTTPServerMetricAttributesFromHTTPRequest()` function no longer generates the high-cardinality `http.request.content.length` label. (#1031)
18+
1519
## [0.10.0] - 2020-07-29
1620

1721
This release migrates the default OpenTelemetry SDK into its own Go module, decoupling the SDK from the API and reducing dependencies for instrumentation packages.

semconv/http.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,15 @@ func httpCommonAttributesFromHTTPRequest(request *http.Request) []kv.KeyValue {
151151
if ua := request.UserAgent(); ua != "" {
152152
attrs = append(attrs, HTTPUserAgentKey.String(ua))
153153
}
154+
if request.ContentLength > 0 {
155+
attrs = append(attrs, HTTPRequestContentLengthKey.Int64(request.ContentLength))
156+
}
154157

155158
return append(attrs, httpBasicAttributesFromHTTPRequest(request)...)
156159
}
157160

158161
func httpBasicAttributesFromHTTPRequest(request *http.Request) []kv.KeyValue {
162+
// as these attributes are used by HTTPServerMetricAttributesFromHTTPRequest, they should be low-cardinality
159163
attrs := []kv.KeyValue{}
160164

161165
if request.TLS != nil {
@@ -177,9 +181,6 @@ func httpBasicAttributesFromHTTPRequest(request *http.Request) []kv.KeyValue {
177181
if flavor != "" {
178182
attrs = append(attrs, HTTPFlavorKey.String(flavor))
179183
}
180-
if request.ContentLength > 0 {
181-
attrs = append(attrs, HTTPRequestContentLengthKey.Int64(request.ContentLength))
182-
}
183184

184185
return attrs
185186
}

0 commit comments

Comments
 (0)