Any way to track custom statistics in locust

落花浮王杯 提交于 2019-12-11 19:30:58

问题


Locust is a great and simple load testing tool. By default it only tracks response times and content length from which it can deduce RPS, etc. Is there any way to track custom statistics in locust as well?

In my case a site Im testing returns couple of stats via headers. For example a count of SQL queries within a request. It would be very helpful to track some of these statistics in conjunction to tracking standard response times.

I do not see any way to do that in locust however. Is there a simple way for doing that?

Only customization I could see is setting url names in a request in docs.

Manually storing some of the stats is not that straight forward either as locust is distributed so would like to avoid doing anything custom.

edit

There is an example how custom stats can be passed around however that does not show up in the UI and requires custom export. Any way to add additional data in locust which will get logged both in UI and data export?

Maybe something like:

class MyTaskSet(TaskSet):
    @task
    def my_task(self):
        response = self.client.get("/foo")
        self.record(foo=response.headers.get('x-foo'))

回答1:


As far as I know, there is no simple way of visualizing custom data in Locust. However, by looking at https://github.com/locustio/locust/blob/master/locust/main.py#L370, you could easily replace main locust run function and inject some custom logic to https://github.com/locustio/locust/blob/master/locust/web.py. This seem to be a low hanging fruit for the Locust devs to make this part of code more adjustable out of the box so I'd suggest opening issue in their GitHub.



来源:https://stackoverflow.com/questions/52596327/any-way-to-track-custom-statistics-in-locust

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