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

Setup body wrapper in otelmux #6650

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

martinyonatann
Copy link

@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
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@dmathieu dmathieu added the Skip Changelog Allow PR to succeed without requiring an addition to the CHANGELOG label Jan 20, 2025
Copy link

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 68.8%. Comparing base (9a53a30) to head (ac6d68a).
Report is 4 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   68.7%   68.8%   +0.1%     
=======================================
  Files        200     202      +2     
  Lines      16872   16968     +96     
=======================================
+ Hits       11601   11690     +89     
- Misses      4927    4933      +6     
- Partials     344     345      +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%) ⬇️

... and 6 files with indirect coverage changes

w.writeHeader(http.StatusOK)
}

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

Check warning

Code scanning / CodeQL

Reflected cross-site scripting Medium

Cross-site scripting vulnerability due to
user-provided value
.
@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
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
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
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.

3 participants