Skip to content

Setup body wrapper in otelmux#6650

Merged
dmathieu merged 7 commits into
open-telemetry:mainfrom
martinyonatann:feat/body-wrapper-for-otelmux
Jan 30, 2025
Merged

Setup body wrapper in otelmux#6650
dmathieu merged 7 commits into
open-telemetry:mainfrom
martinyonatann:feat/body-wrapper-for-otelmux

Conversation

@martinyonatann
Copy link
Copy Markdown
Contributor

@martinyonatann martinyonatann commented Jan 20, 2025

setup and implementation of a body wrapper in the go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux package

This PR addresses feedback provided in #6648

@martinyonatann martinyonatann requested a review from a team as a code owner January 20, 2025 12:32
@github-actions github-actions Bot requested a review from akats7 January 20, 2025 12:32
@martinyonatann martinyonatann force-pushed the feat/body-wrapper-for-otelmux branch from c0b62ee to 21809eb Compare January 20, 2025 12:34
Comment thread CHANGELOG.md Outdated
Comment thread CHANGELOG.md Outdated
@dmathieu dmathieu added the Skip Changelog Allow PR to succeed without requiring an addition to the CHANGELOG label Jan 20, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 20, 2025

Codecov Report

Attention: Patch coverage is 92.30769% with 9 lines in your changes missing coverage. Please review.

Project coverage is 73.1%. Comparing base (f1bdc8b) to head (9b3f581).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...trumentation/github.com/gorilla/mux/otelmux/mux.go 76.6% 5 Missing and 2 partials ⚠️
...rilla/mux/otelmux/internal/request/body_wrapper.go 93.7% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #6650     +/-   ##
=======================================
+ Coverage   73.0%   73.1%   +0.1%     
=======================================
  Files        189     191      +2     
  Lines      15773   15858     +85     
=======================================
+ Hits       11519   11598     +79     
- Misses      3920    3925      +5     
- Partials     334     335      +1     
Files with missing lines Coverage Δ
...ux/otelmux/internal/request/resp_writer_wrapper.go 100.0% <100.0%> (ø)
...rilla/mux/otelmux/internal/request/body_wrapper.go 93.7% <93.7%> (ø)
...trumentation/github.com/gorilla/mux/otelmux/mux.go 85.0% <76.6%> (-4.3%) ⬇️

w.writeHeader(http.StatusOK)
}

n, err := w.ResponseWriter.Write(p)

Check warning

Code scanning / CodeQL

Reflected cross-site scripting

Cross-site scripting vulnerability due to [user-provided value](1).
@dmathieu dmathieu changed the title setup and implementation of a body wrapper in otelmux Setup body wrapper in otelmux Jan 21, 2025
// TODO: The wrapped http.ResponseWriter doesn't implement any of the optional
// types (http.Hijacker, http.Pusher, http.CloseNotifier, etc)
// that may be useful when using it in real life situations.
type RespWriterWrapper struct {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this still apply, since the way you wrap the default writer preserves the original implemented interfaces. Why would you want to implement them in RespWriterWrapper directly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this package is a copy from the otelhttp one.
https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/instrumentation/net/http/otelhttp/internal/request

Which makes me think maybe it should be templatized instead, to ensure things remain in sync.

martinyonatann added a commit to martinyonatann/opentelemetry-go-contrib that referenced this pull request Jan 24, 2025
Copy link
Copy Markdown
Contributor

@akats7 akats7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@dmathieu dmathieu merged commit e49abb5 into open-telemetry:main Jan 30, 2025
@MrAlias MrAlias added this to the v1.35.0 milestone Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Skip Changelog Allow PR to succeed without requiring an addition to the CHANGELOG

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants