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

Added a stats-success-breakdown flag for more detailed status code specific response statistics #296

Merged
merged 3 commits into from
Sep 5, 2023

Conversation

wjhoward
Copy link
Contributor

@wjhoward wjhoward commented Aug 28, 2023

Edit: This comment is now out of date, see additional comments below

Added a command line flag success-stats-only which when set includes only successful (2xx responses) when measuring the Response time histogram and distribution statistics (as per issue: #212 )

The below example was generated using a backend server which returns slow 5xx responses. The left terminal is running with the default options, and the right terminal has the new flag set. As you can see, the slow 5xx responses are excluded from the right terminal:

image

The same flag is applied to the JSON equivalent fields.

I did investigate adding a test for this:

  • Adding a new warp handler to return non 2xx responses for every other request
  • Adding a test which runs an oha command with 2 requests, asserting that when the success flag is set only a single response would appear in the output (2nd request would be a 5xx)

Although I stopped as it was a little tricky, and I wanted to see what the initial response to the PR was first.
Can proceed with adding the test if the changes here make sense.

@hatoo
Copy link
Owner

hatoo commented Aug 29, 2023

Thanks!

It looks Success rate: is broken, I think those shouldn't be 100% even if --success-stats are presented.

I think it's better to print response times for all of

  1. All responses
  2. Only succeeding responses
  3. Only non-succeeding responses

Yes, it's verbose but --success-stats flag should be a rare case so it's not required to be simple.

@hatoo
Copy link
Owner

hatoo commented Aug 29, 2023

For testing, there are no tests for outputs.
We can proceed it without tests for now.

@wjhoward
Copy link
Contributor Author

Thanks @hatoo , so just to clarify you are suggesting that when the flag is set the summary would include 3 sections for both the Response time histogram and Response time distribution sections, e.g:

Response time histogram:
  // all requests
  0.016 [1]  |
  ...

Response time histogram (2xx only):
  0.016 [1]  |
...

Response time histogram (non 2xx):
  0.016 [1]  |

In addition the JSON would also need to include the 3 sections.

I think we would probably then want to change the flag name, e.g. something like stats-success-breakdown

@hatoo
Copy link
Owner

hatoo commented Aug 30, 2023

@wjhoward
Exactly.

I think we would probably then want to change the flag name, e.g. something like stats-success-breakdown.

Yeah, the flag name should be changed and stats-success-breakdown seems good 👍

@wjhoward
Copy link
Contributor Author

wjhoward commented Aug 30, 2023

@hatoo Regarding the broken Success rate: % I believe that's broken in the existing code (I've not actually changed that) - I can raise an issue and we can track fixing that separately?

EDIT: Actually I can just fix that in this PR - may be easier 😄

@hatoo
Copy link
Owner

hatoo commented Aug 30, 2023

@wjhoward
Sorry, I misunderstood, the Success rate is a number for lower levels of protocol stack e.g. socket error or something, so 100% is OK.
So It should be untouched.

@wjhoward
Copy link
Contributor Author

wjhoward commented Sep 1, 2023

With the recent changes the summary output looks like this:
image

The JSON output also includes the new fields only if the flag is set:
image

Successful status codes include 2xx only.
Not successful status codes includes 4xx and 5xx only.

Need to test this more. Does this match your thinking @hatoo ?

@wjhoward wjhoward changed the title Added a success_stats_only flag for filtering response statistics Added a stats-success-breakdown flag for more detailed status code specific response statistics Sep 1, 2023
@hatoo
Copy link
Owner

hatoo commented Sep 1, 2023

LGTM 👍 .
Please proceed.

@wjhoward
Copy link
Contributor Author

wjhoward commented Sep 4, 2023

@hatoo I've tested this and it works as I would expect. Ideally it would be nice to include output tests in the test suite for validating this, but understand that it's non trivial.
I've also updated the CHANGELOG.md file.
Let me know if you want me to update anything else?

@hatoo hatoo merged commit d7b9dcb into hatoo:master Sep 5, 2023
37 of 38 checks passed
@hatoo
Copy link
Owner

hatoo commented Sep 5, 2023

Thank you!
Merged. It's perfect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants