Skip to content

Commit a756609

Browse files
pellaredrltoSD
authored and
rltoSD
committed
otelmux: fix: Do not require calling Write nor WriteHeader (#1443)
* Change tests to make it failing * Fix otelmux to not require calling Write nor WriteHeader * Update changelog * Fix changelog * Fix * Refactor
1 parent 894750e commit a756609

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
1515
### Fixed
1616

1717
- The `"go.opentelemetry.io/contrib/detector/aws/ecs".Detector` no longer errors if not running in ECS. (#1426, #1428)
18+
- `go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux`
19+
does not require instrumented HTTP handlers to call `Write` nor
20+
`WriteHeader` anymore. (#1443)
1821

1922
## [1.2.0/0.27.0] - 2021-11-15
2023

@@ -46,7 +49,7 @@ Update dependency on the `go.opentelemetry.io/otel` project to `v1.1.0`.
4649
- Add instrumentation for the `github.com/aws/aws-lambda-go` package. (#983)
4750
- Add resource detector for AWS Lambda. (#983)
4851
- Add `WithTracerProvider` option for `otelhttptrace.NewClientTrace`. (#1128)
49-
- Add optional AWS X-Ray configuration module for AWS Lambda Instrumentation (#984)
52+
- Add optional AWS X-Ray configuration module for AWS Lambda Instrumentation. (#984)
5053

5154
### Fixed
5255

instrumentation/github.com/gorilla/mux/otelmux/mux.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,12 @@ var rrwPool = &sync.Pool{
8383
func getRRW(writer http.ResponseWriter) *recordingResponseWriter {
8484
rrw := rrwPool.Get().(*recordingResponseWriter)
8585
rrw.written = false
86-
rrw.status = 0
86+
rrw.status = http.StatusOK
8787
rrw.writer = httpsnoop.Wrap(writer, httpsnoop.Hooks{
8888
Write: func(next httpsnoop.WriteFunc) httpsnoop.WriteFunc {
8989
return func(b []byte) (int, error) {
9090
if !rrw.written {
9191
rrw.written = true
92-
rrw.status = http.StatusOK
9392
}
9493
return next(b)
9594
}

instrumentation/github.com/gorilla/mux/otelmux/test/mux_test.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ import (
3030
"go.opentelemetry.io/otel/trace"
3131
)
3232

33-
func ok(w http.ResponseWriter, _ *http.Request) {
34-
w.WriteHeader(http.StatusOK)
35-
}
33+
func ok(w http.ResponseWriter, _ *http.Request) {}
3634

3735
func TestSDKIntegration(t *testing.T) {
3836
sr := tracetest.NewSpanRecorder()

0 commit comments

Comments
 (0)