How to invoke a GRPC python client in locust?

萝らか妹 提交于 2020-04-18 05:45:52

问题


Is there any way to invoke GRPC python client in locust.

The output is generated when I run the code locust -f 1.py. But the stats are not working. They are idle.

users are swarming, but the stats are idle for everything


回答1:


When you build your own client you need to report samples to locust yourself (because how would it otherwise know what you had done?)

In current stable locust version you'd do something like:

from locust import events,
events.request_success.fire(request_type="grpc", name=name, response_time=total_time_calculated_by_you, response_length=your_response_length)

https://docs.locust.io/en/stable/testing-other-systems.html

In latest master / 1.0, it would be something like this (if you're calling this from your TaskSet, if you are already in the Locust class, skip the .locust part):

self.locust.environment.events.request_success.fire(request_type="grpc", name=name, response_time=total_time_calculated_by_you, response_length=your_response_length)

https://docs.locust.io/en/latest/testing-other-systems.html



来源:https://stackoverflow.com/questions/61120975/how-to-invoke-a-grpc-python-client-in-locust

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!