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

Automatically logging response time distribution for each requests made #3809

Closed
nptri opened this issue Jun 25, 2024 · 6 comments
Closed

Automatically logging response time distribution for each requests made #3809

nptri opened this issue Jun 25, 2024 · 6 comments
Assignees

Comments

@nptri
Copy link

nptri commented Jun 25, 2024

Feature Description

Hi, currently I'm learning k6, but to put in a response time log on each requests are kind of weird IMO, if I were to going have a workflow like 5-10 API requests, I would expect that the results output will cover response time (90 - 99th percentile) for each request, or at least, I can call to a function that log and graph response time automatically, instead of initiate a new trend.

Suggested Solution (optional)

Something maybe like:

export function API_Request() {
    //API body def...
    request.log(true) //something like this.
}

Already existing or connected issues / PRs (optional)

Currently I'm using "Trend", but it is a real pain if I try to define Trend for every single API call.

@nptri
Copy link
Author

nptri commented Jul 3, 2024

Hi @mstoykov
As a gentle tag, hope you don't find this frustrating.
I just want to see comment if this feature is possible?

@mstoykov
Copy link
Contributor

mstoykov commented Jul 3, 2024

Hi @nptri, sorry for the slow reply 🙇 :(

I am not really certain I understood what you are trying to do, and I think the problem is usage of the world "log".

By the way you've worded it I would expect you want a line on the terminal each time a request is done.

But I expect you actually want to get metrics about the request? And

I would expect that the results output will cover response time (90 - 99th percentile) for each request,

To be about the end of test summary ?

And given the part about Trend I expect you are tried to work around it by having separate Trend for each of your different requests.

Please see grafana/k6-docs#205 for potential workaround and previous times this was discussed. #1321 is the likely thing that might make this easier, although no concrete implementation plans on that have been made and there are probably more questions that have come up since last it was discussed.

In general the end of test summary is meant for a quick look at results for very simple scripts. K6 is not a visualization tool or metric storage solution. So it is highly advised for any more complicated cases that you use on of the outputs(or an extension) and then visualize them in another solution (grafana for example ;) ) based on the metric tags.

Hope this helps you, and sorry for the delay in response 🙇

@mstoykov mstoykov added question and removed triage labels Jul 3, 2024
@nptri
Copy link
Author

nptri commented Jul 3, 2024

Hi @mstoykov , please refer to my image attached:
image
As you can see I have put a "trend" that shows getUserData_Response_Time and updateNewUsers_Response_Time, to do this, in my script I have to put like this:

let APITrend = new Trend('updateNewUser_Response_Time'); //this is to let the chart to log request

export function update_NewUser () {
    //req body
    APITrend.add(String(req_Package.timings.duration)); //this line right here
    console.log('Response time of Package was ' + String(req_Package.timings.duration) + ' ms'); //also this for terminal log
}

As I am not a pure developer but a QA, IMO, this is a weird way just to get a request statistics in html report. If I were to repeat this for every request, it will be a time-waste process. I just suggest/ask if there could be a shorter way to express this, as it will help a lot, for QA and devs ;)
Cheers !

@mstoykov
Copy link
Contributor

mstoykov commented Jul 3, 2024

@nptri what are you using for your visualization above?

@nptri
Copy link
Author

nptri commented Jul 3, 2024

@mstoykov I just use default visualization html report, as I'm new to k6.

@mstoykov
Copy link
Contributor

mstoykov commented Jul 3, 2024

I guess you mean the web dashboard, although the layout is slightly off.

In that case you are hitting grafana/xk6-dashboard#160 or other related issues.

Given that this has already been reported, and we have two different issues in two different repos I am going to close this issue now.

@mstoykov mstoykov closed this as not planned Won't fix, can't repro, duplicate, stale Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants