-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Custom http_code stats #73
Comments
Hi! You want to look at the locust.events.report_to_master and locust.events.slave_report event hooks (http://docs.locust.io/en/latest/api.html#locust.events.report_to_master). The report_to_master is fired on slave nodes periodically and provides a dict where you can attach data which you will then be able to read out in the slave_report event listener on the master node. Here's a small example: def on_report_to_master(client_id, data):
""" This method is fired periodically on the slave nodes """
data["number_of_404"] = MyCustomStats.number_of_404
# reset the number since it's aggregated on the master node
MyCustomStats.number_of_404 = 0
def on_slave_report(client_id, data):
""" This method id fired on the master node, every time a slave report comes in """
MyCustomStats.number_of_404 += data["number_of_404"]
events.report_to_master += on_report_to_master
events.slave_report += on_slave_report The stuff you put in the data dict, in your report_to_master listener, should be serializable by MessagePack (http://msgpack.org). I hope this can be of help! |
I'm closing this issue now, but feel free to re-open it if you need more pointers! |
Hi,
I have hacked up locust to provide me with some custom stats, so that I can count the different occurrences of certain status codes. So far I have this working well when running the process by itself however, If fails to give me the stats when running in distributed mode.
I guess I need to do something here to send the stats back from the slave to the master or for the master to recognise them. Would someone be able to point me in the correct direction please ?
Thanks
Mark
The text was updated successfully, but these errors were encountered: