From baddb54244544f5c9874fd61fe2b0bab87ddb862 Mon Sep 17 00:00:00 2001 From: Anthony J Mirabella Date: Tue, 4 Aug 2020 18:01:11 -0400 Subject: [PATCH 1/2] 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(). --- instrumentation/othttp/handler_test.go | 1 - semconv/http.go | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/instrumentation/othttp/handler_test.go b/instrumentation/othttp/handler_test.go index 3d98481c29a..f5fbbaf66e3 100644 --- a/instrumentation/othttp/handler_test.go +++ b/instrumentation/othttp/handler_test.go @@ -72,7 +72,6 @@ func TestHandlerBasics(t *testing.T) { semconv.HTTPSchemeHTTP, semconv.HTTPHostKey.String(r.Host), semconv.HTTPFlavorKey.String(fmt.Sprintf("1.%d", r.ProtoMinor)), - semconv.HTTPRequestContentLengthKey.Int64(3), } assertMetricLabels(t, labelsToVerify, meterimpl.MeasurementBatches) diff --git a/semconv/http.go b/semconv/http.go index 785581c6234..b82fef93f65 100644 --- a/semconv/http.go +++ b/semconv/http.go @@ -151,11 +151,15 @@ func httpCommonAttributesFromHTTPRequest(request *http.Request) []kv.KeyValue { if ua := request.UserAgent(); ua != "" { attrs = append(attrs, HTTPUserAgentKey.String(ua)) } + if request.ContentLength > 0 { + attrs = append(attrs, HTTPRequestContentLengthKey.Int64(request.ContentLength)) + } return append(attrs, httpBasicAttributesFromHTTPRequest(request)...) } func httpBasicAttributesFromHTTPRequest(request *http.Request) []kv.KeyValue { + // as these attributes are used by HTTPServerMetricAttributesFromHTTPRequest, they should be low-cardinality attrs := []kv.KeyValue{} if request.TLS != nil { @@ -177,9 +181,6 @@ func httpBasicAttributesFromHTTPRequest(request *http.Request) []kv.KeyValue { if flavor != "" { attrs = append(attrs, HTTPFlavorKey.String(flavor)) } - if request.ContentLength > 0 { - attrs = append(attrs, HTTPRequestContentLengthKey.Int64(request.ContentLength)) - } return attrs } From edc6e7e8386844740968e8beb4e830b42a24c564 Mon Sep 17 00:00:00 2001 From: Anthony J Mirabella Date: Wed, 5 Aug 2020 10:34:43 -0400 Subject: [PATCH 2/2] Add CHANGELOG entry --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2316885b77b..0f6b193aa1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - 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) +### Fixed + +- The `semconv.HTTPServerMetricAttributesFromHTTPRequest()` function no longer generates the high-cardinality `http.request.content.length` label. (#1031) + ## [0.10.0] - 2020-07-29 This release migrates the default OpenTelemetry SDK into its own Go module, decoupling the SDK from the API and reducing dependencies for instrumentation packages.