-
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
Allow user-defined tags based on response data for built-in metrics (e.g. value of a certain HTTP header) #3940
Comments
Hey @frittentheke, Thanks for your request. Could you please extend your proposal? We would appreciate a detailed feature request, so we can dig straight into possible implementations, their the pros & cons, feasibility, etc - rather than designing a new feature from scratch. 🙇🏻 |
Thanks @joanlopez for getting back to me this quickly!
Certainly! The sole difference to the existing capabilities of the check function is the time additional (user-defined) tags are defined. Currently one has to set the tags and their value statically prior to calling
I like to use data from the (HTTP) response though to enrich e.g. the In my particular case the intended tag values come from certain headers in the 5xx and 4xx responses to which currently ( k6/lib/netext/httpext/transport.go Line 77 in 93667ec
x-envoy-overloaded header (envoyproxy/envoy#15106) which I'd like to distinguish in my metrics from other 503 responses - so to separate 503 from Envoy (Istio Service Mesh) and the application itself.
But my use-case is NOT limited to failed requests. Successful responses could also be distinguished by certain headers and their value in the response, for example by indicating if a request was served from a cache (e.g. AWS Cloudfront While I certainly can introduce a k6/lib/netext/httpext/transport.go Line 77 in 93667ec
|
Thanks for the extended answer @frittentheke! 🙇🏻 Could you provide one or two ways of how would you like to define such metrics, with an example like the one you provided to show how it could be achieved now? Like, having a Thanks! |
Currently one has to use a custom metric to use data from the response:
With just defining headers that should be extracted and added to the built-in metrics as tags, this solution is a little clunky.
|
Hi @frittentheke, I've been thinking about this for some time, and now I'm wondering how feasible this would be, because I had a look at the code involved in setting up user-defined tags, and that's typically done right before running the associated function (the HTTP request, the check function, etc). So, enabling a mechanism to define tags based on the "output" of such functions, dynamically, wouldn't mean only having to make tags accept some sort of callback instead of static key-value pairs, but also specifically injecting that logic on each operation that accepts tags now. That would require a much larger change, and I don't think we have the capacity now to focus on that. However, let me invoke @mstoykov, because he knows the system much better than me, so maybe he has a nice workaround or idea of how to implement such a feature without having to do very big changes. Thanks! 🙇🏻 |
Feature Description
I know it's possible to add tags at various stages and abstraction levels: https://grafana.com/docs/k6/latest/using-k6/tags-and-groups/#user-defined-tags. But this has to happen before the operation and apparently it's not possible to dynamically extract a tag based on the response data, e.g. when calling fail.
In my case I'd like to extract more details from 4xx or 5xx errors (certain HTTP headers indicating a more detailed reason for the failure). I know I can create a custom metric and apply a tag based on the response. But I'd much rather add another tag or two to the built-in metrics.
A somewhat related question might be this one here: #680
Suggested Solution (optional)
No response
Already existing or connected issues / PRs (optional)
No response
The text was updated successfully, but these errors were encountered: