MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / parse_summary

Function parse_summary

tests/loadtest/tools/dashboard_parser.py:169–233  ·  view source on GitHub ↗
(name: str, payload: dict[str, Any])

Source from the content-addressed store, hash-verified

167
168
169def parse_summary(name: str, payload: dict[str, Any]) -> dict[str, Any]:
170 metrics = payload.get("metrics", {})
171 http_reqs = metric_values(metrics, "http_reqs")
172 failed = metric_values(metrics, "http_req_failed")
173 checks_metric = metric_values(metrics, "checks")
174 duration_metric = (
175 metric_values(metrics, "http_req_duration{expected_response:true}")
176 or metric_values(metrics, "http_req_duration")
177 )
178 vus = metric_values(metrics, "vus")
179 vus_max = metric_values(metrics, "vus_max")
180
181 request_rate = to_float(http_reqs.get("rate"))
182 overview = {
183 "requestsTotal": to_float(http_reqs.get("count")),
184 "requestRate": request_rate,
185 "throughputPerMinute": request_rate * 60 if request_rate is not None else None,
186 "successRate": 1 - to_float(failed.get("rate")) if to_float(failed.get("rate")) is not None else None,
187 "checkRate": to_float(checks_metric.get("rate")),
188 "avgMs": to_float(duration_metric.get("avg")),
189 "p50Ms": to_float(duration_metric.get("med")),
190 "p95Ms": to_float(duration_metric.get("p(95)")),
191 "p99Ms": to_float(duration_metric.get("p(99)")),
192 "maxMs": to_float(duration_metric.get("max")),
193 "vus": to_float(vus.get("value")),
194 "vusMax": to_float(vus_max.get("max") or vus_max.get("value")),
195 "dataSentBytes": to_float(metric_values(metrics, "data_sent").get("count")),
196 "dataReceivedBytes": to_float(metric_values(metrics, "data_received").get("count")),
197 }
198
199 checks = []
200 for check in payload.get("root_group", {}).get("checks", []):
201 passes = to_float(check.get("passes")) or 0
202 fails = to_float(check.get("fails")) or 0
203 total = passes + fails
204 checks.append(
205 {
206 "name": check.get("name") or "Unnamed check",
207 "passes": passes,
208 "fails": fails,
209 "rate": (passes / total) if total else None,
210 }
211 )
212
213 thresholds: list[dict[str, Any]] = []
214 for metric_name, definition in metrics.items():
215 metric_thresholds = definition.get("thresholds", {})
216 for label, result in metric_thresholds.items():
217 thresholds.append(
218 {
219 "metric": metric_name,
220 "label": f"{metric_name} {label}",
221 "ok": bool(result.get("ok")),
222 }
223 )
224
225 return {
226 "kind": "k6_summary",

Callers 1

parse_textFunction · 0.85

Calls 3

metric_valuesFunction · 0.85
to_floatFunction · 0.85
build_statsFunction · 0.85

Tested by

no test coverage detected