Skip to content

Commit

Permalink
Fix incorrectly updating stat history
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbaldwin44 committed Nov 8, 2024
1 parent bb0efad commit c3a779c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion locust/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def get_html_report(
{**exc, "nodes": ", ".join(exc["nodes"])} for exc in environment.runner.exceptions.values()
]

update_stats_history(environment.runner)
if stats.history and stats.history[-1]["time"] < end_time:
update_stats_history(environment.runner, end_time)
history = stats.history

is_distributed = isinstance(environment.runner, MasterRunner)
Expand Down
7 changes: 4 additions & 3 deletions locust/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,9 +902,9 @@ def sort_stats(stats: dict[Any, S]) -> list[S]:
return [stats[key] for key in sorted(stats.keys())]


def update_stats_history(runner: Runner) -> None:
def update_stats_history(runner: Runner, timestamp: str | None = None) -> None:
stats = runner.stats
timestamp = format_utc_timestamp(time.time())
timestamp = timestamp or format_utc_timestamp(time.time())
current_response_time_percentiles = {
f"response_time_percentile_{percentile}": [
timestamp,
Expand All @@ -929,7 +929,8 @@ def stats_history(runner: Runner) -> None:
while True:
if not runner.stats.total.use_response_times_cache:
break
if runner.state != "stopped":

if runner.state != "ready" and runner.state != "stopped":
update_stats_history(runner)

gevent.sleep(HISTORY_STATS_INTERVAL_SEC)
Expand Down

0 comments on commit c3a779c

Please sign in to comment.