Skip to content

Commit

Permalink
fix(apdex): show all metrics in report (#2210)
Browse files Browse the repository at this point in the history
  • Loading branch information
InesNi authored Oct 13, 2023
1 parent 331ee21 commit 683e569
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/artillery-plugin-apdex/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ class ApdexPlugin {

function apdexAfterResponse(req, res, userContext, events, done) {
const total = res.timings.phases.total;
const counts = {};
if (total <= t) {
events.emit('counter', METRICS.satisfied, 1);
counts.satisfied = 1;
} else if (total <= 4 * t) {
events.emit('counter', METRICS.tolerated, 1);
counts.tolerated = 1;
} else {
events.emit('counter', METRICS.frustrated, 1);
counts.frustrated = 1;
}
events.emit('counter', METRICS.satisfied, counts.satisfied);
events.emit('counter', METRICS.tolerated, counts.tolerated);
events.emit('counter', METRICS.frustrated, counts.frustrated);

return done();
}
Expand Down
25 changes: 25 additions & 0 deletions packages/artillery-plugin-apdex/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,28 @@ test('apdex plugin works when other after response hooks are set', async (t) =>
'After Response Handler did not run five times'
);
});

// Related to the following discussion: https://github.com/artilleryio/artillery/discussions/2209
test('apdex plugin reports all apdex metrics even if they never occured', async (t) => {
//Arrange: Plugin overrides
const override = JSON.stringify({
config: {
plugins: { apdex: {} },
apdex: {
threshold: 100
}
}
});

//Act: run the test
const output =
await $`../artillery/bin/run run ./test/fixtures/scenario.yml --overrides ${override}`;
const allMetricsReported =
output.stdout.includes('apdex.satisfied:') &&
output.stdout.includes('apdex.tolerated:') &&
output.stdout.includes('apdex.frustrated:');
t.ok(
allMetricsReported,
'All Apdex metrics counters are displayed in the report'
);
});

0 comments on commit 683e569

Please sign in to comment.