Home > front end >  Locust treats APIs with path parameters as different APIs
Locust treats APIs with path parameters as different APIs

Time:06-29

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)

CodePudding user response:

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

  • Related