-
Notifications
You must be signed in to change notification settings - Fork 573
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
tests(otelhttp): fixes the body replacement in otelhttp to not to mutate a nil body. #484
tests(otelhttp): fixes the body replacement in otelhttp to not to mutate a nil body. #484
Conversation
…ate a nil body. This might break tests when they attempt to read the body when the body isn't nil.
11d34b9
to
18cb7b6
Compare
@jmacd could you please review/merge this? This PR fixes a bug that is affecting us. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
if isReqBodyNil { | ||
setAfterServeAttributes(span, 0, rww.written, rww.statusCode, nil, rww.err) | ||
} else { | ||
setAfterServeAttributes(span, bw.read, rww.written, rww.statusCode, bw.err, rww.err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you avoid these conditionals by setting bw
to an empty bodyWrapper
above and not replacing r.Body
with it? It looks like these are just providing the empty values for those fields if the request body is nil.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a good idea. Let me try that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@XSAM @Aneurysm9 could we please include this in 0.15? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Aneurysm9 Since we do not actually release the v0.15.0
tag, maybe we should include this?
@jchengsfx The last commit fails the compilation.
Co-authored-by: Sam Xie <xsambundy@gmail.com>
Co-authored-by: Sam Xie <xsambundy@gmail.com>
@XSAM done |
Thanks all, shall we merge it?
On Sat, 12 Dec 2020 at 10:25, Anthony Mirabella ***@***.***> wrote:
***@***.**** approved this pull request.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#484 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAXOYARPQNXPBM3DETGMSBDSUMZJTANCNFSM4USN7GEQ>
.
--
|
This upgrade aims to prepare goagent to include the changes in open-telemetry/opentelemetry-go-contrib#484 in the next commit.
…b#484 in the opentelemetry contrib dependency.
* chore(opentelemetry): upgrades opentelemetry to 0.15.0. This upgrade aims to prepare goagent to include the changes in open-telemetry/opentelemetry-go-contrib#484 in the next commit. * chore(opentelemetry): includes open-telemetry/opentelemetry-go-contrib#484 in the opentelemetry contrib dependency. * tests(opencensus): improves coverage of the setAttribute method. * tests(opentelemetry): adds coverage for setAttribute.
…tallNewPipeline (#484) Co-authored-by: Rahul Patel <rghetia@yahoo.com>
This might break tests when they attempt to read the body when the body isn't nil.
When using a http server, the body received by the handler is
http.noBody
whereas when calling directly the handler it receivesnil
. Whether calling the handler directly with a request is the best way to do it or not, by adding the handler in tests we get anil
pointer as any attempt to read a nonnil
body ends up trying to read aio.ReadCloser
which is actuallynil
(and ends up in anil pointer
fatal error). This creates the so called "observer effect".Related to hypertrace/goagent#66
Ping @XSAM @MrAlias @Aneurysm9