artillery-plugin-apdex 1.0.0-2f484f8 → 1.0.0-331ee21

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.
Files changed (2) hide show
  1. package/index.js +30 -22
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -15,34 +15,42 @@ class ApdexPlugin {
15
15
  constructor(script, _events) {
16
16
  this.script = script;
17
17
 
18
- const t =
19
- script.config.apdex?.threshold ||
20
- script.config.plugins.apdex?.threshold ||
21
- 500;
18
+ if (
19
+ global.artillery &&
20
+ Number(global.artillery.version.slice(0, 1)) > 1 &&
21
+ typeof process.env.LOCAL_WORKER_ID !== 'undefined'
22
+ ) {
23
+ const t =
24
+ script.config.apdex?.threshold ||
25
+ script.config.plugins.apdex?.threshold ||
26
+ 500;
22
27
 
23
- if (!script.config.processor) {
24
- script.config.processor = {};
25
- }
28
+ if (!script.config.processor) {
29
+ script.config.processor = {};
30
+ }
26
31
 
27
- script.scenarios.forEach(function (scenario) {
28
- scenario.afterResponse = [].concat(scenario.afterResponse || []);
29
- scenario.afterResponse.push('apdexAfterResponse');
30
- });
32
+ script.scenarios.forEach(function (scenario) {
33
+ scenario.afterResponse = [].concat(scenario.afterResponse || []);
34
+ scenario.afterResponse.push('apdexAfterResponse');
35
+ });
31
36
 
32
- function apdexAfterResponse(req, res, userContext, events, done) {
33
- const total = res.timings.phases.total;
34
- if (total <= t) {
35
- events.emit('counter', METRICS.satisfied, 1);
36
- } else if (total <= 4 * t) {
37
- events.emit('counter', METRICS.tolerated, 1);
38
- } else {
39
- events.emit('counter', METRICS.frustrated, 1);
37
+ function apdexAfterResponse(req, res, userContext, events, done) {
38
+ const total = res.timings.phases.total;
39
+ if (total <= t) {
40
+ events.emit('counter', METRICS.satisfied, 1);
41
+ } else if (total <= 4 * t) {
42
+ events.emit('counter', METRICS.tolerated, 1);
43
+ } else {
44
+ events.emit('counter', METRICS.frustrated, 1);
45
+ }
46
+
47
+ return done();
40
48
  }
41
49
 
42
- return done();
43
- }
50
+ script.config.processor.apdexAfterResponse = apdexAfterResponse;
44
51
 
45
- script.config.processor.apdexAfterResponse = apdexAfterResponse;
52
+ return;
53
+ }
46
54
 
47
55
  global.artillery.ext({
48
56
  ext: 'beforeExit',
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "artillery-plugin-apdex",
3
- "version": "1.0.0-2f484f8",
3
+ "version": "1.0.0-331ee21",
4
4
  "description": "Calculate and report Apdex scores",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "exit 0"
7
+ "test": "export ARTILLERY_TELEMETRY_DEFAULTS='{\"source\":\"test-suite\"}' && tap ./test/*.spec.js --timeout 300 --no-coverage --color"
8
8
  },
9
9
  "keywords": [],
10
10
  "author": "",