fix(contrib/net/http): when Wrapping use the WrappedHandler #4079
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Uses a previously unused type to wrap the httphandler. On the surface this is a no-op, but in practice the enables targeted changes to http tracing that orchestrion does.
Motivation
We've been using orchestrion (to great effect) but had noticed a memory leak due to tracing in one of our services. This service exposed both rest and grpc using https://pkg.go.dev/golang.org/x/net/http2/h2c. Orchestrion happily wraps the serve mux, but under the hood h2c hijacks the incoming connection for grpc calls and fails to "complete" the parent trace. This ends up leading to a "forever parent" that accumulates references to children until the app OOM's
Orchestrion does not support overriding the behavior but it does skip wrapping if the type it sees is already one of the wrapped types, which means we can manually instrument just the part of the h2c server thats problematic to handle this case!
Open to other ideas to solve this, but the type was there and already in the orchestrion logic so this seemed like a reasonable line!
sample configuration (in case you want to reproduce)
after!
Reviewer's Checklist
./scripts/lint.shlocally.Unsure? Have a question? Request a review!