Skip to content

Commit 4b9320e

Browse files
p3rf Teamcopybara-github
authored andcommitted
Add locust_overall/<metric> metrics.
These metrics are equivalent to the last locust/<metric> metrics, but are added to ease selection of them for graphing purposes. PiperOrigin-RevId: 715852464
1 parent c2954a8 commit 4b9320e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

perfkitbenchmarker/linux_packages/locust.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,21 @@ def Run(
137137
stdout, _, _ = vm.RunCommand(['cat', 'test1_stats_history.csv'])
138138
yield from _ConvertLocustResultsToSamples(stdout)
139139

140+
# Grab the last line again and re-export those samples as the "locust_overall"
141+
# samples. NB:
142+
# 1. CSV outputs sequentially so last line is last timestamp
143+
# 2. Timestamps continue to aggregate, so last timestamp is "overall".
144+
stdout, _, _ = vm.RunCommand(
145+
'(head -n1 && tail -n1) < test1_stats_history.csv'
146+
)
147+
yield from _ConvertLocustResultsToSamples(
148+
stdout, metric_namespace='locust_overall'
149+
)
150+
140151

141152
def _ConvertLocustResultsToSamples(
142153
locust_results: str,
154+
metric_namespace: str = 'locust',
143155
) -> Iterable[sample.Sample]:
144156
"""Converts each csv row from locust to a PKB sample."""
145157
lines = locust_results.splitlines()
@@ -153,7 +165,7 @@ def _ConvertLocustResultsToSamples(
153165
continue
154166

155167
yield sample.Sample(
156-
metric='locust/' + _SanitizeFieldName(field),
168+
metric=metric_namespace + '/' + _SanitizeFieldName(field),
157169
value=float(row[field]),
158170
unit='',
159171
metadata={},

0 commit comments

Comments
 (0)