-
Notifications
You must be signed in to change notification settings - Fork 579
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
otelhttp response writer implementation does not track WriteHeader
when Flush
is called
#5438
Comments
Could you give us the implementation of your flusher? opentelemetry-go-contrib/instrumentation/net/http/otelhttp/handler_test.go Lines 27 to 35 in a91e60b
Which makes sense, because the wrapped response writer is a RecorderTest, for which Flush is implemented there: This method will only write the header if it hasn't been written yet (and Should your flusher implementation be doing the same check? |
@dmathieu This is the stdlib implementation from a standard net/http.Server |
For reference, here is how we fixed this in moby: moby/moby#47796 |
All right, it wasn't happening in tests because the log only happens in the runtime response implementation, not in httptest. I have opened a fix in #5634. |
Thanks for jumping on that! |
@dmathieu Thanks for making the PR fix for this issue. I'm seeing right now that it has conflicts with the target branch. Do you have an idea of when this will be resolved and a new release issued? A service I work on that has an indirect dependency on |
Thank you. I have rebased the branch. As for releases, they happen about once a month. |
It seems that somehow this fix got reverted in some renames... opentelemetry-go-contrib/instrumentation/net/http/otelhttp/internal/request/resp_writer_wrapper.go Lines 82 to 85 in bb3cf24
The fix that disappeared: 9479910 I just upgraded to
|
Description
When using the otelhttp wrapper to instrument an http endpoint, the wrapper is doing its own tracking to determine if
WriteHeader
should be called during aWrite
.However the wrapper does not implement
http.Flusher
, as such whenFlush()
is called on the http.ResponseWriter the undrlying flusher from net/http is called, however otelhttp is not aware that the headers have already been written.When a subsequent call to
Write
is made, otelhttp callsWriteHeader
first, which has already been called on the underlying net/http implementation, and we wend up with a log printed from net/http:Environment
otelhttp
version: v0.46.1Steps To Reproduce
Basic example:
Expected behavior
Since otelhttp is doing its own tracking in its
Write
implementation for when to callWriteHeader
, it needs to be aware of whenFlush
is called.The text was updated successfully, but these errors were encountered: