k6
k6 copied to clipboard
Refactor `group()` and `check()` tight coupling with the `VU.State`
This tight coupling is preventing us from implementing group() and check() purely in JavaScript. It is also preventing us from implementing similar functions, but with better UX (e.g. https://github.com/grafana/k6/issues/1066, https://github.com/grafana/k6/issues/2865) or that work better with async / await (https://github.com/grafana/k6/issues/2848, https://github.com/grafana/k6/issues/2728)
The tight coupling can be removed with only a very small loss of efficiency, by just having the MetricEngine process check and group_duration metrics as they appear and group them based on their group tag. Here is what basically needs to be removed:
https://github.com/grafana/k6/blob/1d99b0be9194bf9aaf86c070dd0d34604f266abe/lib/vu_state.go#L41-L42
https://github.com/grafana/k6/blob/1d99b0be9194bf9aaf86c070dd0d34604f266abe/lib/runner.go#L71-L72
https://github.com/grafana/k6/blob/1d99b0be9194bf9aaf86c070dd0d34604f266abe/js/modules/k6/k6.go#L98-L104
https://github.com/grafana/k6/blob/1d99b0be9194bf9aaf86c070dd0d34604f266abe/js/modules/k6/k6.go#L169
For the record. After an internal discussion, we decided to clean a milestone since the issue was jumping between milestones without completion.
Once we determine which milestone it lands, we set the right one.