xk6-browser
xk6-browser copied to clipboard
Support custom tags in page.goto() and other relevant methods
Currently, we have the ability to support custom tags in k6 core when using http.get()
or http.post()
. This allows us to customise reports, thresholds or other use cases. See the below code snippet for reference.
http.get('https://test.k6.io/contacts.php', {
tags: { my_custom_tag: 'contacts' },
});
This is currently not supported in xk6-browser specific methods such as page.goto()
. I have a use case where I want to specify different thresholds per pages and the easiest way is to use tags like the one below:
export const options = {
...
thresholds: {
'browser_dom_content_loaded{customTag:messages}': ['p(90) < 1000'],
'browser_dom_content_loaded{customTag:news}': ['p(90) < 800'],
browser_first_contentful_paint: ['max < 1000']
}
};
export function messages() {
/// some other code
page.goto('https://test.k6.io/my_messages.php', {
// This custom tag doesn't work as expected
tags: { customTag: 'messages' },
waitUntil: 'networkidle'
})
}
There are other ways of course to specify different thresholds such as filtering it by default tags such as url
or the name
metric but it would still be nice to support custom tags going forward.
Resources
- https://github.com/grafana/xk6-websockets/pull/28/files
- How to get the storage from lib.State
- How to set from the got JS object
- How to emit metrics with tags
### Tasks
- [ ] Support [user defined](https://grafana.com/docs/k6/latest/using-k6/tags-and-groups/#user-defined-tags) tags in browser APIs as a new option field.
- [ ] Ensure [test-wide](https://grafana.com/docs/k6/latest/using-k6/tags-and-groups/#test-wide-tags) tags is supported by the browser module.
- [ ] Ensure [code defined](https://grafana.com/docs/k6/latest/using-k6/tags-and-groups/#code-defined-tags) tags is supported by the browser module.
- [ ] Ensure [tagged stages](https://grafana.com/docs/k6/latest/using-k6/tags-and-groups/#tagging-stages) works with the browser module.
- [ ] Define and support [system tags](https://grafana.com/docs/k6/latest/using-k6/tags-and-groups/#system-tags).
Hi @imiric, it would be really nice to have such improvement. I also saw that it is confusing and difficult to deal with name metrics etc. Is there any decision made or progress on this issue? Thanks for your answer.