-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Thresholds aren't triggered when custom metrics aren't used #1053
Comments
This is also an issue for us as it's causing our tests to always fail when the counter has no value. Is it possible to initialise the counter with a 0 value instead? Our test configuration export let Errors = new Rate("errors");
export let options = {
thresholds: {
"errors": [{
threshold: "rate<0.1" // <10% errors
}],
"http_req_duration": [{
threshold: "p(99)<1200",
delayAbortEval: "10s"
}]
}
};
export default function (data) {
var number = data.numbers[Math.floor(Math.random() * data.numbers.length)];
group("Request payment", function () {
const paymentResponse = payments.requestAsync(helper.createPaymentRequest(number));
check(paymentResponse, {
"status is 201 (Created)": (r) => r.status == 201,
"payment is approved": (r) => JSON.parse(paymentResponse.body).approved == true
}) || Errors.add(1);
});
} |
@ben-foster-cko, while there's a bug with the way thresholds are evaluated when no metrics are emitted, in your case the problem is that you're using the
Then the threshold "fail if there were errors in more than 10% (of the total number of events)" makes sense. Or, put another way, if you're only adding to the metric when there's an error, then you have an error counter, not a rate - you can't know in how many cases there wasn't an error. In your case, since Errors.add(!check(paymentResponse, {
"status is 201 (Created)": (r) => r.status == 201,
"payment is approved": (r) => JSON.parse(paymentResponse.body).approved == true
})); |
Thanks, I figured this out last night and was just about to post with an update :) |
I did just take a few hours trying to figure out why a threshold I added wasn't showing up ... the answer: I defined it depending on the "vu" tag and it isn't enabled by default. I do think though that just like it should be triggered it should always be shown and in this case possibly include a warning "No data was received for this threshold through the execution of the script" |
Closing in favor of #1346 |
This script should always fail, but instead it only fails roughly 50% of the time, when the
counter not used
branch is executed:The text was updated successfully, but these errors were encountered: