-
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
How to access built-in metrics after the test completion #351
Comments
Basically all I was looking for was the ability to send build statistics to TeamCity at the very end of the test run. I'm open to other options (e.g. an option to get aggregated data as JSON output), but I like the default output from the tests, so what would be ideal for me would be something like this: import { metrics } from "k6"; // Or somewhere else logical -- this is just to access the built in metrics
// A function that (if defined) runs _after_ the script has finished
// i.e. when all iterations are done and data from all nodes in the cluster have been correlated
export function teardown() {
const http_req_duration = metrics.http_req_duration.results(); // Just a method to extract the statistics
console.log(`##teamcity[buildStatisticValue key='AverageDuration' value='${http_req_duration.avg}']`);
} In the meantime I've worked around it by manually calculating the aggregated data myself (extracting the duration after each request), but this will obviously not work in a clustered scenario or with multiple iterations. |
|
We could give #194 the ability to do this, the problem is that it'd have implications for clustered execution. Every k6 instance in a test would need to keep their samples in memory and push them to a "main" instance that could then call Using One way to solve this would be (as I mentioned in #321) to log in a binary format and offer commands to interact with this format. This is something we can make work in a sane and performant fashion, although a distributed test would end up with one file per node. |
Related issue at #321
Based on the above Slack comment and other similar questions. I think there is a common case to easily access the aggregated metric results after the test completion.
Add a tutorial how to process the JSON output with jq.
Discuss if a
k6
output option could provide this metric information or bring back "Aggregated metrics in JSON format" Aggregated metrics in JSON format #274. This option looks to be removed with the CLI refactor.The text was updated successfully, but these errors were encountered: