Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

otelmux: fix: Do not require calling Write nor WriteHeader #1443

Merged
merged 6 commits into from
Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +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)

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

Expand Down Expand Up @@ -46,7 +49,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

Expand Down
3 changes: 1 addition & 2 deletions instrumentation/github.com/gorilla/mux/otelmux/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ import (
"go.opentelemetry.io/otel/trace"
)

func ok(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
}
func ok(w http.ResponseWriter, _ *http.Request) {}

func TestSDKIntegration(t *testing.T) {
sr := tracetest.NewSpanRecorder()
Expand Down