Expose an on_hatch event? And/or hatch number (e.g. we just hatched user number X) as well
See original GitHub issueThe API docs mention a hatch_complete
event hook. That’s useful but I don’t always care to know about all users started (could monitor from other metrics in the test environment).
What could be useful to me is a way to track a hatch event, to do something on hatch.
On a related note, it would also be helpful to know what each hatched user’s number is (when they hatched as in I’m user number X). Helpful for data association to users based on ID/number. You don’t always want to do it randomly, sometimes yes.
So, could we get an on_hatch
event hook?
What would be nice also would be if we could get whatever locust uses to track the current hatch count (or equivalent) available as an attribute to read from. Something like JMeter’s thread number/count property where in code you can figure out which user/thread number you are for whatever load logic you are trying to do. (e.g. self.locust.hatch_number
)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:14 (4 by maintainers)
Top GitHub Comments
Hrm, I see what you are saying - you want effectively a “locust id” of sorts that you can use within the context of the on_start.
I wonder if something like that would be worth adding or finding a way to expose. I know at least one person who would find it beneficial (cc @thomaslevans-wf)
This is unlikely to be built into Locust, because it would be hard to do when running Locust distributed. Slave nodes operate independently of each other, and when new nodes connect the master rebalances the simulated users across the nodes.
Please note that when running this in a slave node, this will only report the number of simulated users running in that node. Slave nodes do not know of the other running nodes.