Skip to content
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

fix(apdex): show all metrics in report #2210

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
);
});