Search code examples
locust

Collect (and chart/analyze) additional metrics with Locust


I'm trying to load test an API whose response exposes some additional custom metrics and attributes which aren't fully controllable from the request side but are known to correlate with performance: Along the lines of internal cache hit/miss (boolean), retrieved intermediate values that affected the overall servicing time (scalar), etc.

What would the recommended pattern(s) be to save this additional request-level information and be able to:

  1. Filter or compare latency charts/metrics by the other metric values
  2. View the distribution of the other non-latency metrics over the duration of the test

It looks like the context parameter in the Request Event might be an option for my custom User class to emit the data? But I'm not sure from the docs if this would actually allow slicing the results.

If analysis functionality in the locust UI itself is limited, maybe there's a way to dump the data to a structured file like Parquet or etc that we could analyze offline - but in such a way that would minimize impact to the achievable throughput per worker process?


Solution

  • The context parameter is only used by custom request event handlers, the Locust UI doesn't support filtering/slicing by anything and definitely not by context.

    You can either make your own handler that writes to something (like Parquet, or just a regular SQL database).

    I you don't want to build it yourself you can use Locust Dashboards (but it isn't very user friendly to set up, and I'm not really maintaining it any more)

    Or you can sign up for Locust Cloud, which provides this feature.