-
Notifications
You must be signed in to change notification settings - Fork 232
fix: instrumentation of http.request
et al has a few edge cases
#3090
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
The cleaning up reproRun this server: % cat issue2382-server.example.js
const express = require('express')
const app = express()
app.get('/ping', (req, res) => {
res.send('pong')
})
app.listen(3000)
% node issue2382-server.example.js Then run this client request script ( require('.').start({ // elastic-apm-node
serviceName: 'example-outgoing-http-ipv6-boom',
cloudProvider: 'none',
metricsInterval: '0s',
centralConfig: false,
captureExceptions: false,
logUncaughtExceptions: true,
disableSend: true
})
var http = require('http')
var theUrl = 'http://[::1]:3000/ping'
http.get(theUrl, function (res) {
console.log('res:', res.statusCode, res.headers)
res.on('data', (chunk) => { console.log('data: %s', chunk) })
res.on('end', () => { console.log('end') })
}) without the fix:
and with this PR:
|
http|https.request|get
has a few edge caseshttp.request
et al has a few edge cases
…oosey-goosey usage of 'http.request(...)' et al
…3100) The test for `error.exception.module` for a reported APM error using `@elastic/elasticsearch` broke with the recent `8.6.0` version... as installed by the npm in node v14. The issue was that the install tree changed such that the error stack top frame was in: node_modules/@elastic/elasticsearch/node_modules/@elastic/transport/lib/Transport.js rather than: node_modules/@elastic/transport/lib/Transport.js for reasons independent of the `@elastic/[email protected]` release. The `_moduleNameFromFrames` utility didn't handle a nested `node_modules/...` dir. This change fixes that.
Support for tracing/monitoring Azure Functions. Supported triggers/bindings: HTTP (spec'd), Timer (not spec'd). Spec: elastic/apm#716 Closes: #3015 Co-authored-by: Brandon Morelli <[email protected]>
trentm
added a commit
that referenced
this pull request
Jan 18, 2023
The 'http.request' instrumentation fix in #3090 uncovered a bug in our tests for @hapi/hapi when with node v8 (a version before `http.request(url, opts, cb)` was supported in node). This fixes that. This also updates the .tav.yml section for '@hapi/hapi' to align with logic in "_is_hapi_incompat.js" so the TAV tests don't waste time installing a version of Hapi for which tests will be skipped anyway. Refs: #3090
trentm
added a commit
that referenced
this pull request
Jan 18, 2023
The 'http.request' instrumentation fix in #3090 uncovered a bug in our tests for @hapi/hapi when with node v8 (a version before `http.request(url, opts, cb)` was supported in node). This fixes that. This also updates the .tav.yml section for '@hapi/hapi' to align with logic in "_is_hapi_incompat.js" so the TAV tests don't waste time installing a version of Hapi for which tests will be skipped anyway. Refs: #3090
PeterEinberger
pushed a commit
to fpm-git/apm-agent-nodejs
that referenced
this pull request
Aug 20, 2024
…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
PeterEinberger
pushed a commit
to fpm-git/apm-agent-nodejs
that referenced
this pull request
Aug 20, 2024
The 'http.request' instrumentation fix in elastic#3090 uncovered a bug in our tests for @hapi/hapi when with node v8 (a version before `http.request(url, opts, cb)` was supported in node). This fixes that. This also updates the .tav.yml section for '@hapi/hapi' to align with logic in "_is_hapi_incompat.js" so the TAV tests don't waste time installing a version of Hapi for which tests will be skipped anyway. Refs: elastic#3090
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This change updates the argument munging that is done for the wrapping
of
http.request
et al to fix some cases where the instrumentationwould 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()
tonew URL()
. Recentversions of node have a
url.urlToHttpOptions()
to help with thisconversion.
Fixes: #2044
Fixes: #2382
Refs: https://discuss.elastic.co/t/issue-apm-agent-with-backend-requests-username-password-url/322903