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

Make resetting stats after hatching configurable #289

Closed
wants to merge 1 commit into from
Closed

Make resetting stats after hatching configurable #289

wants to merge 1 commit into from

Conversation

pglass
Copy link
Contributor

@pglass pglass commented May 30, 2015

This adds a global variable locust.runners.RESET_STATS_AFTER_HATCHING that you can use from a locust file, as well as a command line flag --no-reset-stats. Locust should still default to resetting the statistics and the "Reset Stats" link in the web interface should work regardless of this flag.

Resolves #205

* By default, stats are reset after hatching
* Added a cli flag --no-reset-stats to disable stats resetting
* Can also set locust.runners.RESET_STATS_AFTER_HATCHING = False
from within a locust file
* This does not affect the "Reset stats" link in the web interface
@billibala
Copy link

thanks for this patch! saves me hours of debug time.

@BeardedUnicorn
Copy link

I just wanted to comment to support this PR.

We have been using locust for load testing, but we have started to venture into determining if all insert records stemmed from the API are making it into our database. Unfortunately with the reset happening after everything is hatched, makes this task difficult, when it shouldn't be.

As an example, if I hatch 10000 users, there will be 8000-11000 requests prior to the stats being reset. Which means the counts themselves will be off. If we are going to compare the number of requests made by locust, to the number of records in the database, it will appear that the database has more records than it should.

@marklynch
Copy link

Adding a vote to this - about to do some similar testing that @secretobsession described so having this merged in would be great.

@cgoldberg
Copy link
Member

+1

12 similar comments
@nhoening
Copy link

+1

@adionditsak
Copy link

+1

@alexandrul
Copy link

+1

@Slach
Copy link

Slach commented May 4, 2016

+1

@jjstellr
Copy link

+1

@JordyvanDortmont
Copy link

+1

@di
Copy link
Contributor

di commented Sep 9, 2016

+1

@TimGerlach
Copy link

+1

@swordmaster2k
Copy link

+1

@shun-liang
Copy link

+1

@partojkander
Copy link

+1

@dimakr
Copy link

dimakr commented Nov 25, 2016

+1

@titleistfour
Copy link

+1

Just starting using locust and ran into the same issue were requests did not match the database records. Would be really great to get this finally merged in.

@@ -392,6 +399,11 @@ def main():
logger.error("Locust can not run distributed with the web interface disabled (do not use --no-web and --master together)")
sys.exit(0)

if options.no_reset_stats:
runners.RESET_STATS_AFTER_HATCHING = False
if not runners.RESET_STATS_AFTER_HATCHING:
Copy link
Member

Choose a reason for hiding this comment

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

This if condition is unnecessary in my opinion. Why not just log when setting the flag to False?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I remember right (after 2 years), it was to handle the case where the module flag was set to false by anything other than the --no-reset-stats flag. For example, if the locust file imports the module and sets that global flag to false.

Copy link
Member

Choose a reason for hiding this comment

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

I removed the log message all together, and changed so that we don't use the module level variable for controlling the reset behaviour. Let me know if you think that's a bad idea.

@heyman
Copy link
Member

heyman commented Feb 16, 2017

Ok, this has now (finally) been merged. Thank you!

I cherry picked the commit, but changed the implementation slightly (removed the module level variable for setting the reset behaviour, and removed the log about the setting).

@heyman heyman closed this Feb 16, 2017
@heyman heyman added this to the 0.8.0 milestone Feb 16, 2017
@alvissd
Copy link

alvissd commented Mar 7, 2017

Hi, is this implemented in version 0.8a2? I have read the change log and download but it seems like nothing changed from 0.7.5

@aldenpeterson-wf
Copy link
Contributor

@alvissd it shows up in the v0.8a1 release commits:

v0.8a1...master

From feb 17th that commit is in there.

@alvissd
Copy link

alvissd commented Mar 8, 2017

@aldenpeterson-wf thanks, I just found it in the source code. Somehow pip install locustio=0.8a2 doesn't install the newest.

@wormhoudt
Copy link

I can confirm that this is not in 0.8a1 or 0.8a2 on PyPi. I can see that it is in the source code, it just isnt available when installing through pip.

@heyman
Copy link
Member

heyman commented Sep 19, 2017

The first version it's in is 0.8a3 I think. v0.8a1...master will show commits that are not in v0.8a1 I think :)?

0.8 is released on PyPI now.

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

Successfully merging this pull request may close these issues.

Option to prevent stats from being reset when all locusts are hatched