Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Commit

Permalink
Fix Artillery v2 detection
Browse files Browse the repository at this point in the history
This plugin is compatible with Artillery Core v1.7.x. The only time
we don't want it loaded is when running under v2 *and* when we're not in
one of the worker threads.
  • Loading branch information
hassy committed Sep 15, 2021
1 parent 7bda320 commit fc155a6
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ let useOnlyRequestNames;

// NOTE: Will not work with `parallel` - need request UIDs for that
function MetricsByEndpoint(script, events) {
if(!global.artillery || !global.artillery.log) {
console.error('artillery-plugin-metrics-endpoint requires Artillery v2');
return;
}

if (typeof process.env.WORKER_ID === 'undefined') {
// if(!global.artillery || !global.artillery.log) {
// console.error('artillery-plugin-metrics-endpoint requires Artillery v2');
// return;
// }

// If running in Artillery v2, the plugin should only load in workers
if (global.artillery &&
Number(global.artillery.version.slice(0, 1)) > 1 &&
typeof process.env.LOCAL_WORKER_ID === 'undefined') {
debug('Not running in a worker, exiting');
return;
}
Expand Down

0 comments on commit fc155a6

Please sign in to comment.