Skip to content
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

Better url aggregating functionality #927

Closed
marklagendijk opened this issue Feb 20, 2019 · 4 comments
Closed

Better url aggregating functionality #927

marklagendijk opened this issue Feb 20, 2019 · 4 comments
Labels
enhancement evaluation needed proposal needs to be validated or tested before fully implementing it in k6 new-http issues that would require (or benefit from) a new HTTP API ux

Comments

@marklagendijk
Copy link
Contributor

marklagendijk commented Feb 20, 2019

In the documentation about Aggregating results for HTTP requests it says:

By default, requests report the name tag with the value of the request URL. For URLs that contain dynamic parts this might not be desirable since it can introduce a large number of unique URLs in the metrics stream.

However, this means that one needs to do this for every url that is affected by this (in our case most of the urls).
Also, this does not play nice in combination with response.submitForm(), because with response.submitForm() the url is read from the HTML form in the response, and may be unknown to the developer.

I have 2 proposals to solve this issue in a nice way.

1. Remove query parameter values

I would propose to remove the query param values from the default name tag. This feature should be optional. You could argue that it should be on by default, but for backwards compatibility this might not be desirable. When enabled the default name tag for https://example.com?t=1 or https://example.com?t=2 would become something like https://example.com?t=[]

2. Allow specifying a function that calculates the name tag

Proposal 1 only solves the issue for query parameters, but path parameters can have the same issue.
A solution which would work for all cases is to allow specifying a function as value for a tag.
Example:

response.submitForm({
  params: {
    tags: {
      name: request => request.url.replace(/\/path\/.*/, '/path')
    }
  }
});
@marklagendijk marklagendijk changed the title Automatic url aggregating for query strings Better url aggregating functionality Feb 20, 2019
@na--
Copy link
Member

na-- commented Feb 21, 2019

Thanks for the issue, I think both proposals have merit and would be useful!

The new option, which you're correct to say should be disabled by default for backwards compatibility, probably needs to only be accessible as an environment variable and a script option. I don't think it would merit a CLI flag at this time, though we can always add it later.

Regarding implementation specifics for the second one, I'd prefer if the callback wasn't part of the tags map, rather I think it should be specified directly in the params root. And if we're going to have a callback anyway, we might as well get more use out of it. It can be something that accepts the whole tags map (and likely the request and response objects as well) before k6 emits it and could modify whatever the user needs, including the name tag.

There will be some difficulties with implementing this callback in both cases though, just because of how the k6 HTTP request making code is structured, but I don't think they are insurmountable... And the whole feature could also be made more useful when we implement those two issues: #761 and #884

@marklagendijk
Copy link
Contributor Author

The new option, which you're correct to say should be disabled by default for backwards compatibility, probably needs to only be accessible as an environment variable and a script option. I don't think it would merit a CLI flag at this time, though we can always add it later.

I agree.

Regarding implementation specifics for the second one, I'd prefer if the callback wasn't part of the tags map, rather I think it should be specified directly in the params root. And if we're going to have a callback anyway, we might as well get more use out of it. It can be something that accepts the whole tags map (and likely the request and response objects as well) before k6 emits it and could modify whatever the user needs, including the name tag.

Nice idea! That would make the feature a lot more powerful. When we have this we can just add an example in the aggregating http request results documentation using this callback.

And the whole feature could also be made more useful when we implement those two issues: #761 and #884

Nice issues! I already thought about creating one for default options, but nice that it is already there 😃.

@na-- na-- added the evaluation needed proposal needs to be validated or tested before fully implementing it in k6 label Aug 27, 2019
marklagendijk pushed a commit to Connected-Information-systems/k6 that referenced this issue Sep 23, 2019
@marklagendijk
Copy link
Contributor Author

I implemented the first proposal in #1171

@olegbespalov
Copy link
Contributor

olegbespalov commented Nov 22, 2023

Closing in favor of #2461, which is inspired by a design doc of a new HTTP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement evaluation needed proposal needs to be validated or tested before fully implementing it in k6 new-http issues that would require (or benefit from) a new HTTP API ux
Projects
None yet
Development

No branches or pull requests

3 participants