Skip to content

Commit 44e169e

Browse files
Add numeric elapsed_seconds to metrics JSON
Resolves #2506 genMetrics.py stores stage runtimes as human-readable strings (e.g., "0:04.26") which are hard to consume programmatically. This adds numeric elapsed_seconds fields (in seconds as floats) alongside the existing string fields so runtimes are directly usable for analysis and plotting. New fields added per stage: - <stage>__elapsed_seconds (float, seconds) - total_elapsed_seconds (float, seconds) Existing fields (runtime__total, total_time) are unchanged. Signed-off-by: Harsh Kumar Patwa <harshkumarpatwa@gmail.com> Signed-off-by: Harsh Kumar <harshkumar3446@gmail.com>
1 parent d205bf1 commit 44e169e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

flow/util/genMetrics.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ def extract_metrics(
315315

316316
failed = False
317317
total = timedelta()
318+
elapsed_seconds = {}
318319
for key in metrics_dict:
319320
if key.endswith("__runtime__total"):
320321
# Big try block because Hour and microsecond is optional
@@ -341,10 +342,16 @@ def extract_metrics(
341342
)
342343
total += delta
343344

345+
stage = key.removesuffix("__runtime__total")
346+
elapsed_seconds[stage + "__elapsed_seconds"] = delta.total_seconds()
347+
344348
if failed:
345349
metrics_dict["total_time"] = "ERR"
346350
else:
347351
metrics_dict["total_time"] = str(total)
352+
metrics_dict["total_elapsed_seconds"] = total.total_seconds()
353+
354+
metrics_dict.update(elapsed_seconds)
348355

349356
metrics_dict = {
350357
key.replace(":", "__"): value for key, value in metrics_dict.items()

0 commit comments

Comments
 (0)