Ah, this is similar to Ignore http calls made in Setup or Teardown in results? - #2 by nedyalko, and as I mention there, until we fix Add explicit tracking and ignoring of metrics and sub-metrics · Issue #1321 · grafana/k6 · GitHub there are some workarounds that are required to ignore metrics from setup()
and teardown()
.
The easiest one is to surface a sub-metric of http_req_duration
that doesn’t include them. And until we fix that issue, the easiest hack to do that is to set a bogus threshold on it, like this for example:
export let options = {
thresholds: {
'http_req_duration{scenario:default}': [`max>=0`],
},
}
If you have multiple scenarios, you can add a custom tag to each via their tags
option and use that instead of scenario:default
. The important thing is to have a sub-metric that doesn’t include the metrics from setup()
and teardown()
and then work with that in handleSummary()
.
There are some more examples in this docs issue: Add example for sub-metrics by scenario (or other tags) in summary · Issue #205 · grafana/k6-docs · GitHub