-
Notifications
You must be signed in to change notification settings - Fork 225
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
instrumentation of http{s}.request()
has a few edge case issues
#2044
Comments
My thinking is similar. Looking at the code here, it appears that that only property of the extracted options variable that our function uses is Here's all the method signatures of
There's two that don't have an options object.
For these method signatures we'll need to generate an empty options object and then either |
This change updates the argument munging that is done for the wrapping of `http.request` et al to fix some cases where the instrumentation would *change the behaviour* of the function. The main fix here is that before this change the conversion of a URL instance to request options would accidentally drop basic auth info (the 'username' and 'password' fields). This issue has existed since v2.17.0. It was introduced in commit dd60b12 when switching directly from `url.parse()` to `new URL()`. Recent versions of node have a `url.urlToHttpOptions()` to help with this conversion. Fixes: #2044 Refs: https://discuss.elastic.co/t/issue-apm-agent-with-backend-requests-username-password-url/322903
This issue has existed since v2.17.0. It was introduced in commit dd60b12 when switching directly from |
) This change updates the argument munging that is done for the wrapping of `http.request` et al to fix some cases where the instrumentation would *change the behaviour* of the function. The main fix here is that before this change the conversion of a URL instance to request options would accidentally drop basic auth info (the 'username' and 'password' fields). This issue has existed since v2.17.0. It was introduced in commit dd60b12 when switching directly from `url.parse()` to `new URL()`. Recent versions of node have a `url.urlToHttpOptions()` to help with this conversion. Fixes: #2044 Fixes: #2382 Refs: https://discuss.elastic.co/t/issue-apm-agent-with-backend-requests-username-password-url/322903
…astic#3090) This change updates the argument munging that is done for the wrapping of `http.request` et al to fix some cases where the instrumentation would *change the behaviour* of the function. The main fix here is that before this change the conversion of a URL instance to request options would accidentally drop basic auth info (the 'username' and 'password' fields). This issue has existed since v2.17.0. It was introduced in commit dd60b12 when switching directly from `url.parse()` to `new URL()`. Recent versions of node have a `url.urlToHttpOptions()` to help with this conversion. Fixes: elastic#2044 Fixes: elastic#2382 Refs: https://discuss.elastic.co/t/issue-apm-agent-with-backend-requests-username-password-url/322903
In lib/instrumentation/http-shared.js the
traceOutgoingRequest
function that handles instrumentinghttp.request
andhttps.request
has a few issues:args
changes the signature ofhttp.request()
such that you can pass any number of objects and URLs to it -- before and after a callback function. Not a biggie.ensureUrl
uses aformatURL
function that is meant to be (or should be) an equivalent to node core's handling (https://github.com/nodejs/node/blob/8d9d8236b79ea91640f973cc8c1423603694b482/lib/internal/url.js#L1288-L1311) but misses a few things:http.request
and HTTP Basic auth in a first URL arg are being brokenI wonder if it would be possible to avoid full processing of the original args, only try to sniff out and update an "options.headers" object. Then the agent doesn't have to try to track change made to node's internal "urlToHttpOptions" handling.
One side-effect of ^^ is that the potential handling for extracting the "url", see #2039, may have to change to handle inspecting those original
args
itself. I believe that would be preferable to changing the behaviour ofhttp.request
.The text was updated successfully, but these errors were encountered: