@artilleryio/int-core 2.0.6 → 2.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/engine_http.js +7 -0
- package/lib/runner.js +2 -1
- package/package.json +1 -1
package/lib/engine_http.js
CHANGED
|
@@ -656,6 +656,7 @@ HttpEngine.prototype.step = function step(requestSpec, ee, opts) {
|
|
|
656
656
|
requestParams.retry = 0; // disable retries - ignored when using streams
|
|
657
657
|
|
|
658
658
|
const uuid = crypto.randomUUID();
|
|
659
|
+
let totalDownloaded = 0;
|
|
659
660
|
request(requestParams)
|
|
660
661
|
.on('request', function (req) {
|
|
661
662
|
ee.emit('trace:http:request', requestParams, uuid);
|
|
@@ -664,6 +665,9 @@ HttpEngine.prototype.step = function step(requestSpec, ee, opts) {
|
|
|
664
665
|
ee.emit('counter', 'http.requests', 1);
|
|
665
666
|
ee.emit('rate', 'http.request_rate');
|
|
666
667
|
req.on('response', function (res) {
|
|
668
|
+
res.on('end', () => {
|
|
669
|
+
ee.emit('counter', 'http.downloaded_bytes', totalDownloaded);
|
|
670
|
+
});
|
|
667
671
|
ee.emit('trace:http:response', res, uuid);
|
|
668
672
|
self._handleResponse(
|
|
669
673
|
requestParams,
|
|
@@ -676,6 +680,9 @@ HttpEngine.prototype.step = function step(requestSpec, ee, opts) {
|
|
|
676
680
|
});
|
|
677
681
|
|
|
678
682
|
})
|
|
683
|
+
.on('downloadProgress', (progress) => {
|
|
684
|
+
totalDownloaded = progress.total;
|
|
685
|
+
})
|
|
679
686
|
.on('error', function (err, body, res) {
|
|
680
687
|
ee.emit('trace:http:error', err, uuid);
|
|
681
688
|
if (err.name === 'HTTPError') {
|
package/lib/runner.js
CHANGED
|
@@ -386,7 +386,8 @@ function createContext(script, contextVars) {
|
|
|
386
386
|
{
|
|
387
387
|
target: script.config.target,
|
|
388
388
|
$environment: script._environment,
|
|
389
|
-
$processEnvironment: process.env
|
|
389
|
+
$processEnvironment: process.env, // TODO: deprecate
|
|
390
|
+
$env: process.env,
|
|
390
391
|
},
|
|
391
392
|
contextVars || {}
|
|
392
393
|
),
|