From 2cb635ea85e50dc5287436d133cfb498c1551c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 24 Nov 2021 13:39:03 +0100 Subject: [PATCH 1/6] Change tests to make it failing --- instrumentation/github.com/gorilla/mux/otelmux/test/mux_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/instrumentation/github.com/gorilla/mux/otelmux/test/mux_test.go b/instrumentation/github.com/gorilla/mux/otelmux/test/mux_test.go index 0f41e01ab87..bec6d5cac01 100644 --- a/instrumentation/github.com/gorilla/mux/otelmux/test/mux_test.go +++ b/instrumentation/github.com/gorilla/mux/otelmux/test/mux_test.go @@ -31,7 +31,6 @@ import ( ) func ok(w http.ResponseWriter, _ *http.Request) { - w.WriteHeader(http.StatusOK) } func TestSDKIntegration(t *testing.T) { From 88ba4d45269db3c30cd025ef7ec0104f2ea25e2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 24 Nov 2021 13:55:12 +0100 Subject: [PATCH 2/6] Fix otelmux to not require calling Write nor WriteHeader --- instrumentation/github.com/gorilla/mux/otelmux/mux.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/instrumentation/github.com/gorilla/mux/otelmux/mux.go b/instrumentation/github.com/gorilla/mux/otelmux/mux.go index d805e44ea8e..7df7b0cf73f 100644 --- a/instrumentation/github.com/gorilla/mux/otelmux/mux.go +++ b/instrumentation/github.com/gorilla/mux/otelmux/mux.go @@ -83,13 +83,12 @@ var rrwPool = &sync.Pool{ func getRRW(writer http.ResponseWriter) *recordingResponseWriter { rrw := rrwPool.Get().(*recordingResponseWriter) rrw.written = false - rrw.status = 0 + rrw.status = http.StatusOK rrw.writer = httpsnoop.Wrap(writer, httpsnoop.Hooks{ Write: func(next httpsnoop.WriteFunc) httpsnoop.WriteFunc { return func(b []byte) (int, error) { if !rrw.written { rrw.written = true - rrw.status = http.StatusOK } return next(b) } From 04083077c7cab5f26ed8ce7818c728051f8c5a5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 24 Nov 2021 14:02:53 +0100 Subject: [PATCH 3/6] Update changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e53ce06904a..e836847b155 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Fixed - The `"go.opentelemetry.io/contrib/detector/aws/ecs".Detector` no longer errors if not running in ECS. (#1426, #1428) +- `go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux` does not + require instrumented HTTP handlers to call `Write` nor `WriteHeader` anymore. (#1443) ## [1.2.0/0.27.0] - 2021-11-15 @@ -46,7 +48,7 @@ Update dependency on the `go.opentelemetry.io/otel` project to `v1.1.0`. - Add instrumentation for the `github.com/aws/aws-lambda-go` package. (#983) - Add resource detector for AWS Lambda. (#983) - Add `WithTracerProvider` option for `otelhttptrace.NewClientTrace`. (#1128) -- Add optional AWS X-Ray configuration module for AWS Lambda Instrumentation (#984) +- Add optional AWS X-Ray configuration module for AWS Lambda Instrumentation. (#984) ### Fixed From 6cfacbbaf870f65c1ea818c0d853df7eb4f8dc37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 24 Nov 2021 14:04:31 +0100 Subject: [PATCH 4/6] Fix changelog --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e836847b155..ae91d73298e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,8 +15,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Fixed - The `"go.opentelemetry.io/contrib/detector/aws/ecs".Detector` no longer errors if not running in ECS. (#1426, #1428) -- `go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux` does not - require instrumented HTTP handlers to call `Write` nor `WriteHeader` anymore. (#1443) +- `go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux` + does not require from instrumented HTTP handlers to call `Write` nor + `WriteHeader` anymore. (#1443) ## [1.2.0/0.27.0] - 2021-11-15 From 8caab1465a70b8a632fd842d7aced729655859ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 24 Nov 2021 14:05:19 +0100 Subject: [PATCH 5/6] Fix --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae91d73298e..4bcc75fa442 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - The `"go.opentelemetry.io/contrib/detector/aws/ecs".Detector` no longer errors if not running in ECS. (#1426, #1428) - `go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux` - does not require from instrumented HTTP handlers to call `Write` nor + does not require instrumented HTTP handlers to call `Write` nor `WriteHeader` anymore. (#1443) ## [1.2.0/0.27.0] - 2021-11-15 From cfa723b74a5e30a8dc05bd72efc55b230c6ac132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 24 Nov 2021 20:02:38 +0100 Subject: [PATCH 6/6] Refactor --- .../github.com/gorilla/mux/otelmux/test/mux_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/instrumentation/github.com/gorilla/mux/otelmux/test/mux_test.go b/instrumentation/github.com/gorilla/mux/otelmux/test/mux_test.go index bec6d5cac01..78c25b622b4 100644 --- a/instrumentation/github.com/gorilla/mux/otelmux/test/mux_test.go +++ b/instrumentation/github.com/gorilla/mux/otelmux/test/mux_test.go @@ -30,8 +30,7 @@ import ( "go.opentelemetry.io/otel/trace" ) -func ok(w http.ResponseWriter, _ *http.Request) { -} +func ok(w http.ResponseWriter, _ *http.Request) {} func TestSDKIntegration(t *testing.T) { sr := tracetest.NewSpanRecorder()