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

Feature : --exclude-failed-response-time. #2382

Closed
wants to merge 4 commits into from

Conversation

nmondal
Copy link

@nmondal nmondal commented Aug 12, 2023

Issue / Feature:
#2381

@nmondal
Copy link
Author

nmondal commented Aug 14, 2023

Hello @cyberw can you please help us with this?

@cyberw
Copy link
Collaborator

cyberw commented Aug 14, 2023

sorry, on holiday

@cyberw
Copy link
Collaborator

cyberw commented Aug 21, 2023

I'm back :)

I think this could be ok. But you'd need to add a test case that verifies the feature. And remove the shortcut name (-x), as it could conflict with some other parameter that might be added in the future. I have a few questions as well...

if self.parsed_options and self.parsed_options.exclude_failed_response_time:
self.exclude_failed_response_time = True
self.stats = RequestStats(exclude_failed_response_time=self.exclude_failed_response_time)
"""Reference to RequestStats instance"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont understand this comment.

Copy link
Author

@nmondal nmondal Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the same pattern for the rest of the fields.

@@ -148,7 +152,13 @@ def create_worker_runner(self, master_host: str, master_port: int) -> WorkerRunn
"""
# Create a new RequestStats with use_response_times_cache set to False to save some memory
# and CPU cycles, since the response_times_cache is not needed for Worker nodes
self.stats = RequestStats(use_response_times_cache=False)
exclude_failed_response_time = False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is oddly written. why set a variable to false and then do an if statement changing the value?

@cyberw
Copy link
Collaborator

cyberw commented Aug 21, 2023

Hmm.. Iooking more closely at the code it is just not good enough. Too many oddities in the code, and I'd need to spend too much time trying to wrap my head around it. I'm not sure if the old PR worked (#2353), but it was a lot cleaner.

@nmondal
Copy link
Author

nmondal commented Aug 22, 2023

Hmm.. Iooking more closely at the code it is just not good enough. Too many oddities in the code, and I'd need to spend too much time trying to wrap my head around it. I'm not sure if the old PR worked (#2353), but it was a lot cleaner.

It won't work.
Given stats has no clue what to exclude, it won't even know what to do.
That is precisely why we have to carry the flag forward to practically everywhere.

It would only work for the case of the option is set to true, and even then it would have all metrics computed wrong.
For example avg, percentile all of the computation would be broken as well as total.
😢

My first change was exactly the same, and I realized it won't work.
Let me see how more we can simplify.

@@ -71,8 +71,6 @@ def __init__(
"""If set, only tasks that are tagged by tags in this list will be executed. Leave this as None to use the one from parsed_options"""
self.exclude_tags = exclude_tags
"""If set, only tasks that aren't tagged by tags in this list will be executed. Leave this as None to use the one from parsed_options"""
self.stats = RequestStats()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can simplify lines 95-99:

self.stats = RequestStats(
    exclude_failed_response_time=getattr(parsed_options, "exclude_failed_response_time", False)
)

@@ -148,7 +152,13 @@ def create_worker_runner(self, master_host: str, master_port: int) -> WorkerRunn
"""
# Create a new RequestStats with use_response_times_cache set to False to save some memory
# and CPU cycles, since the response_times_cache is not needed for Worker nodes
self.stats = RequestStats(use_response_times_cache=False)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, we can simplify it to:

self.stats = RequestStats(
    use_response_times_cache=False,
    exclude_failed_response_time=getattr(self.parsed_options, "exclude_failed_response_time", False),
)

@cyberw cyberw added the stale Issue had no activity. Might still be worth fixing, but dont expect someone else to fix it label Oct 27, 2023
Copy link

github-actions bot commented Nov 7, 2023

This PR was closed because it has been stalled for 10 days with no activity.

@github-actions github-actions bot closed this Nov 7, 2023
@Alex-TG001
Copy link

Hello, I'm trying to make our final metrics based on what we get from filtering out failed requests. If I changed the logic of the on_requests function like this, would it works?
These codes are in /locust/runners.py
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Issue had no activity. Might still be worth fixing, but dont expect someone else to fix it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants