k6-docs icon indicating copy to clipboard operation
k6-docs copied to clipboard

Documentation about name and url out of sync with implementation

Open mem opened this issue 1 year ago • 2 comments

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 avatar Nov 01 '23 20:11 mem

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 :cry: This is expected behavior since you've specified the name in the group (https://github.com/grafana/k6/pull/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 :cry:

olegbespalov avatar Nov 14 '23 08:11 olegbespalov

As https://github.com/grafana/k6/issues/2584#issuecomment-1219618111 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.

codebien avatar Jan 17 '24 10:01 codebien