In my test cases, I need to “setup” a database with data, and in the end to “teardown” the database - on every test file (I’m using the handleSummary to write the http_req_duration metrics to JSON and then combine all the JSON files to CSV).
I used the setup/teardown functions to leverage the convenience and also used http.batch for the speed (because we setup/teardown 100/1000/10000 “users” to the database)
But what I noticed eventually at the summary was that the setup/teardown HTTP requests (http.batch) were also included in the http_req_duration etc …
Seems a bit strange, I thought that only the VUs default function is measured.
How can I bypass this issue with minimal refactoring? (lot of code written so far).
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:
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().