Allow Metrics to be initialised outside of init code #3035
Labels
evaluation needed
proposal needs to be validated or tested before fully implementing it in k6
feature
Feature Description
Right now trying to init a Trend or other metric from within your exported test function will error.
This prevents test writers from being able to add dynamic trend names based on shared test data.
Given a
SharedArray
readonly struct , I'd like to be able to differentiate tests using data from said struct on a per iteration basis instead of just on a per VU basis.Suggested Solution (optional)
Allowing for trends to be created during script execution would be all that's needed - making each Trend mutable is beyond the scope of this request and likely goes against the core K6 principle of script reusability.
Basically, instead of having Metrics creatable only during the init context, and readable from both the Init and script execution contexts, I think that Metrics should be creatable throughout the script's life cycle as this is technically before reports are finalised anyways (and also before the post script handle summary hook).
Already existing or connected issues / PRs (optional)
No response
The text was updated successfully, but these errors were encountered: