-
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
k6/execution: Add metadata JS API #3037
Conversation
A bare minimum API to set and get metadata set for the whole VU. It is added on top of the vu property and on top of a new `metrics` one so. If `k6/execution` is imported as `exec` - `exec.vu.metrics.metadata["foo"]` will get you the currently set metadata for `foo` the same way `exec.vu.tags["bar"]` will get you the value of the tag `bar`. Setting metadata is the same. It also adds `exec.vu.metrics.tags` which is the same as `exec.vu.tags` for consistency. While leaving the old one for backwards compatibility. This also includes dropping the ability to list metadata keys and values from `exec.vu.tags`. This was likely left in by mistake. This is a breaking change due to the fact that before that `iter` and `vu` could've been accessed this way but this will now need to be done through the new `exec.vu.metrics.metadata`. Closes #2766
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: Ivan <[email protected]>
note: I will just squash at the end |
Codecov Report
@@ Coverage Diff @@
## master #3037 +/- ##
=======================================
Coverage 77.04% 77.05%
=======================================
Files 229 229
Lines 17065 17107 +42
=======================================
+ Hits 13147 13181 +34
- Misses 3077 3084 +7
- Partials 841 842 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just minor suggestions.
js/modules/k6/execution/execution.go
Outdated
}) | ||
err = o.Set("tags", tagsDynamicObject) | ||
|
||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}) | |
err = o.Set("tags", tagsDynamicObject) | |
if err != nil { | |
}) | |
// This is kept for backwards compatibility reasons, but should be deprecated, | |
// since tags are also accessible via vu.metrics.tags. | |
err = o.Set("tags", tagsDynamicObject) | |
if err != nil { |
Also, should we add a deprecation warning when this is first used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to add an issue to discuss if we even want to deprecate it 🤷
Co-authored-by: Ivan Mirić <[email protected]>
documented in grafana/k6-docs#1207 |
A bare minimum API to set and get metadata set for the whole VU.
It is added on top of the vu property and on top of a new
metrics
one so. Ifk6/execution
is imported asexec
-exec.vu.metrics.metadata["foo"]
will get you the currently set metadata forfoo
the same wayexec.vu.tags["bar"]
will get you the value of the tagbar
.Setting metadata is the same.
It also adds
exec.vu.metrics.tags
which is the same asexec.vu.tags
for consistency. While leaving the old one for backwards compatibility.This also includes dropping the ability to list metadata keys and values from
exec.vu.tags
. This was likely left in by mistake.This is a breaking change due to the fact that before that
iter
andvu
could've been accessed this way but this will now need to be done through the newexec.vu.metrics.metadata
.Closes #2766