pythonlocust

Using the "name" argument to group requests


I have a working request like this:

 resp = self.client.get(f'/api/loadValues?tsIds={load_ts_ids_in_function}&resolution={resolution}'
                           f'&startUtc={set_from_date_load_values()}&endUtc={set_to_date_load_values()}',
                           headers={'X-API-KEY': 'xxx'})

But the User’s statistics are not aggregated in the Locust web-gui.

Came across this:

https://docs.locust.io/en/stable/writing-a-locustfile.html#name-parameter

But how do I use the name-argument in the above code?


Solution

  • Like the examples in the doc you linked, you include name='this string is what I want the stats to report as'. So if you wanted them to be grouped as '/api/loadValues' you'd do:

    resp = self.client.get(f'/api/loadValues?tsIds={load_ts_ids_in_function}&resolution={resolution}'
                           f'&startUtc={set_from_date_load_values()}&endUtc={set_to_date_load_values()}',
                           headers={'X-API-KEY': 'xxx'}, name='/api/loadValues')