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

Metrics for which no data was recorded are not displayed or evaluated for Thresholds #1346

Closed
sniku opened this issue Mar 6, 2020 · 3 comments · Fixed by #2426
Closed

Metrics for which no data was recorded are not displayed or evaluated for Thresholds #1346

sniku opened this issue Mar 6, 2020 · 3 comments · Fixed by #2426
Assignees
Labels
Milestone

Comments

@sniku
Copy link
Collaborator

sniku commented Mar 6, 2020

When a custom metric is defined, but no data for that metric is recorded, it's not displayed in the results, and thresholds are not properly evaluated.

It's easiest to show it on an example.

Consider this script.

import { Counter } from 'k6/metrics';
import { sleep } from 'k6';
import http from 'k6/http';

let allErrors = new Counter('error_counter');

export let options = {
  thresholds: {
    error_counter: [
      'count < 10', // 10 of fewer errors are tolerated
    ]
  }
}

export default function () {
  let auth_resp = http.post('https://test-api.k6.io/auth/token/login/', {username: 'test-user', 'password': 'supersecure'});

  if (auth_resp.status >= 400){
    allErrors.add(1, { errorType: 'authError' }); // tagged value creates submetric (useful for making thresholds specific)
  }

  sleep(1);
}

If the test run is successful, the allErrors will contain 0 errors. In that case metric as well as the threshold indicator won't be present in the output.

image

I expected both to be present, just like in this case, when 1 error was recorded:

image

The most problematic manifestation of this bug is when threshold should fail, but doesn't because it's not evaluated.

Example:

import { Counter } from 'k6/metrics';
import { sleep } from 'k6';
import http from 'k6/http';

let allErrors = new Counter('error_counter');

export let options = {
  thresholds: {
    error_counter: [
      'count < 10' // This threshold should fail, but it doesn't
    ]
  }
}

export default function () {
  sleep(1);
}
@sniku sniku added the bug label Mar 6, 2020
@na--
Copy link
Member

na-- commented Mar 6, 2020

A duplicate of #1053, but I'll leave this open, since it's better.

@na--
Copy link
Member

na-- commented May 7, 2020

FWIW, there's an easy workaround for this issue, when it comes to Counter metrics at least: https://community.k6.io/t/looking-for-max-execution-time-option/613/3

@na--
Copy link
Member

na-- commented Feb 1, 2021

#1832 (or something like it) is a prerequisite for the current issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants