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

Documentation about name and url out of sync with implementation #1481

Open
mem opened this issue Nov 1, 2023 · 2 comments
Open

Documentation about name and url out of sync with implementation #1481

mem opened this issue Nov 1, 2023 · 2 comments
Assignees
Labels
Area: OSS Content Improvements or additions to community/oss documentation

Comments

@mem
Copy link

mem commented Nov 1, 2023

Brief summary

The documentation here says that this input:

    http.get(`http://example.com/posts/${id}`, {
      tags: { name: 'PostsItemURL' },
    });

should produce this output:

        "tags": {
            "method":"GET",
            "name":"PostsItemURL",
            "status":"200",
            "url":"http://example.com/1"
        }

In reality it produces this:

        "tags": {
            "method":"GET",
            "name":"PostsItemURL",
            "status":"200",
            "url":"PostsItemURL",
        }

while I do not understand why that is the case (and I would argue that the documented behavior is much more useful; it's what I was actually trying to use), I can see that this was announced in v0.40.0 and it was implemented in v0.41.0.

It's mentioned here, too.

k6 version

0.47.0

OS

Linux

Docker version and image (if applicable)

No response

Steps to reproduce the problem

Use this script:

import http from 'k6/http';

export default function () {
  http.get(`https://swapi.dev/api/planets/1`, {
    tags: {
      name: 'XXX 1',
      group: "xxx",
    },
  });
}

and run it like:

k6 run --vus 1 --iterations 1 --duration 10s --verbose --out=json=test.json  test.js

then look at the output:

{"metric":"http_reqs","type":"Point","data":{"time":"2023-11-01T14:48:51.901713832-06:00","value":1,"tags":{"expected_response":"true","group":"xxx","method":"GET","name":"XXX1","proto":"HTTP/2.0","scenario":"default","status":"200","tls_version":"tls1.2","url":"XXX 1"}}}
...

Expected behaviour

As documented, the output should be:

{"metric":"http_reqs","type":"Point","data":{"time":"2023-11-01T14:48:51.901713832-06:00","value":1,"tags":{"expected_response":"true","group":"xxx","method":"GET","name":"XXX1","proto":"HTTP/2.0","scenario":"default","status":"200","tls_version":"tls1.2","url":"https://swapi.dev/api/planets/1"}}}
...

Actual behaviour

{"metric":"http_reqs","type":"Point","data":{"time":"2023-11-01T14:48:51.901713832-06:00","value":1,"tags":{"expected_response":"true","group":"xxx","method":"GET","name":"XXX1","proto":"HTTP/2.0","scenario":"default","status":"200","tls_version":"tls1.2","url":"XXX 1"}}}
...
mem referenced this issue in grafana/synthetic-monitoring-agent Nov 1, 2023
By adding a `name` tag to each request, we get that in the result as a
`name` label with the corresponding value.

Since the [k6
documentation](https://k6.io/docs/using-k6/http-requests/#url-grouping)
says that setting `name` should not affect `url` but [in reality it
does](https://github.com/grafana/k6/issues/3435), implement a nasty
workaround to preserve the URL. If there's a tag with the special name
`__raw_url__`, use that as the actual URL that was requested.

Modify the generated script so that we add both the `name` tag (set to a
sequential number based on the position of the request in the entries
list) and a `__raw_url__` tag (workaround). Then in the output
extension, include `name` in the metric labels and convert `__raw_url__`
to `url`.

Signed-off-by: Marcelo E. Magallon <marcelo.magallon@grafana.com>
mem referenced this issue in grafana/synthetic-monitoring-agent Nov 2, 2023
By adding a `name` tag to each request, we get that in the result as a
`name` label with the corresponding value.

Since the [k6
documentation](https://k6.io/docs/using-k6/http-requests/#url-grouping)
says that setting `name` should not affect `url` but [in reality it
does](https://github.com/grafana/k6/issues/3435), implement a nasty
workaround to preserve the URL. If there's a tag with the special name
`__raw_url__`, use that as the actual URL that was requested.

Modify the generated script so that we add both the `name` tag (set to a
sequential number based on the position of the request in the entries
list) and a `__raw_url__` tag (workaround). Then in the output
extension, include `name` in the metric labels and convert `__raw_url__`
to `url`.

Signed-off-by: Marcelo E. Magallon <marcelo.magallon@grafana.com>
@olegbespalov
Copy link
Contributor

while I do not understand why that is the case (and I would argue that the documented behavior is much more useful; it's what I was actually trying to use), I can see that this was announced in v0.40.0 and it was implemented in v0.41.0.

Actually, it seems like it's not a bug but the current expected behavior and you just faced the issue that the documentation isn't up to date 😢 This is expected behavior since you've specified the name in the group (grafana/k6#2703).

Off the top of my head, I can't remember what could be the best discussion that explains the rationale, maybe @codebien could help with finding it or bringing the rationale.

But as the actional item, I see that we should create the task to the k6-docs to update the documentation since it could really confusing right now 😢

@olegbespalov olegbespalov removed their assignment Jan 9, 2024
@codebien codebien transferred this issue from grafana/k6 Jan 17, 2024
@codebien codebien self-assigned this Jan 17, 2024
@codebien codebien added the Area: OSS Content Improvements or additions to community/oss documentation label Jan 17, 2024
@codebien
Copy link
Contributor

codebien commented Jan 17, 2024

As grafana/k6#2584 (comment) mentions

however, if the URL value is different from the name tag, then we will save the raw high-cardinality URL value in a new non-indexed raw_url metadata entry, so it's still accessible to users that want it (e.g. in the JSON output)

the raw url has been moved to Metadata. This is now a docs issue as we want to update it to keep it consistent and aligned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: OSS Content Improvements or additions to community/oss documentation
Projects
None yet
Development

No branches or pull requests

3 participants