Locust用路径参数将API视为不同的API

发布于 2025-02-10 15:13:00 字数 399 浏览 1 评论 0原文

在Locust中,我产生了多个用户,这些用户以前缀/api/v1/bots/{bot_id}/在端子上提出请求,其中bot_id是为每个用户唯一生成的。当Locust生成报告时,它将以Bot_id为单独的API的不同值对待每个请求。

例如,该报告显示API

/api/v1/bots/00001/abc
/api/v1/bots/00002/abc
/api/v1/bots/00003/abc
/api/v1/bots/00004/abc

全部是相同的API,而路径中传递的不同参数。有没有办法让蝗虫将它们视为相同的API?

目前,我使用一个单独的脚本来汇总数据,但它带有其自身的问题(不能汇总百分位数)

In locust, I spawn multiple users that make requests to endpoints with the prefix /api/v1/bots/{bot_id}/ where bot_id is uniquely generate for each user. When locust generates a report, it treats each request with a different value for bot_id as a separate API.

For example, the report shows the APIs

/api/v1/bots/00001/abc
/api/v1/bots/00002/abc
/api/v1/bots/00003/abc
/api/v1/bots/00004/abc

All of them are the same APIs with different parameters passed in the path. Is there a way to have locust treat them as the same API?

Currently, I am using a separate script to aggregate the data, but it comes with its own problem (cannot aggregate percentiles)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吃兔兔 2025-02-17 15:13:00

使用name参数,例如

self.client.get(f"/api/v1/bots/{id}/abc", name="/api/v1/bots/<id>/abc")

https://docs.locust.io/en/stable/writing-a-locustfile.html#grouping-requests

Use the name parameter, e.g.

self.client.get(f"/api/v1/bots/{id}/abc", name="/api/v1/bots/<id>/abc")

https://docs.locust.io/en/stable/writing-a-locustfile.html#grouping-requests

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文