locustio / locust

Write scalable load tests in plain Python 🚗💨
https://locust.cloud
MIT License
25.1k stars 3k forks source link

Allow to exclude some statistics from aggregation #2955

Open tyge68 opened 3 weeks ago

tyge68 commented 3 weeks ago

Prerequisites

Description

Currently if our locust script track additional statistics via custom type event, it cannot be excluded from the aggregated line.

Ideally it should be possible to define via script somewhere (via annotation etc...) which metrics are ignored for the aggregation computation, or via ui (similarly to the columns selector).

The reason is that those metrics are mainly to track statistic like "cache missed etc..." detected from CDN response header and so shouldn't be part of the aggregated statistic line data.

Note: the solution is pretty trivial if we hack in the code as it's mainly to add an condition on this line to exclude specific method or name https://github.com/locustio/locust/blob/master/locust/stats.py#L221

What is not trivial is to do it the locust way for me (using annotations or any means to make it configurable) So if someone have more experience in that, it could be good to have some suggestions.

Possible options I see:

What could be filtered out from aggregation are then obviously the following 2 options:

tyge68 commented 3 weeks ago

note it's not clear why Mypy check does the error

locust/stats.py:199: error: Argument 3 to "StatsEntry" has incompatible type "None"; expected "str"  [arg-type]
locust/stats.py:201: error: Need type annotation for "history" (hint: "history: list[<type>] = ...")  [var-annotated]

those lines are not even touched in this PR.