I’m a Senior Software Engineer with Microsoft and currently adding Application Insights to k6 as an output option for 1 of the projects I’m working on.
I thought it’ll be great for community if I can add it to k6 repo.
Honestly, lacking of a good documentation for developing an output plugin is kind of a bummer.
But at least I have a working solution to push results to Application Insights now, I’m just not sure if I’m doing it in a correct way.
Also, I’m a bit confused about the percentiles in the result, I couldn’t get them in Collect() method with stats.SampleContainer argument, and couldn’t understand from the source code in the stats folder.
The k6 outputs/collectors deal only with the raw metric measurement values, e.g. how many milliseconds each HTTP request took, etc. The outputs are supposed to calculate the percentiles themselves, based on these raw values.
The percentiles you see in the summary report k6 produces at the end of the test run are calculated by k6 and are not exposed to the outputs. You can think of the end-of-test summary as sort of a special-case output/collector that crunches the metrics in-memory while the test is running. It’s not quite an output, given that the same percentile calculations are also used for the thresholds, but it’s similar. This is the code that calculates percentiles for Trend metrics.
The k6 engine sends a chunk of metrics to every output every 50 milliseconds. It’s then up to each output to potentially buffer metrics into larger chunks, for example the JSON output flushes them every 200ms, while the InfluxDB output has the period configurable.
We will likely start working on it next week and we should have some rough first version roughly in time for k6 v0.29.0, so mid-November. But I think you’re also misunderstanding what the first version of the plugin system is going to do - it’s not going to allow you to write output plugins, just JS plugins. So, essentially, it would allow you to import more native code in your scripts (e.g. import whatever from "k6/x/whatever"). Support for output plugins would follow in a future version, after we refactor some things and fix the issues with the collector/output APIs I linked to above. I can’t give you a time estimate regarding that, but it’s very unlikely to happen this year, so for now your custom output would have to live in a fork of k6. You can submit a PR for us to merge it, but I can’t give any promises about that either, I pretty much don’t know anything about Application Insights.