Skip to content

Commit 072c898

Browse files
authored
Merge pull request #3943 from harsh-kumar-patwa/add-elapsed-seconds-to-metrics
Add numeric elapsed_seconds to metrics JSON
2 parents a346ff8 + ae7ef79 commit 072c898

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

flow/util/genMetrics.py

Lines changed: 8 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,17 @@ def extract_metrics(
341342
)
342343
total += delta
343344

345+
stage = key[: -len("__runtime__total")]
346+
elapsed_seconds[stage + "__elapsed_seconds"] = delta.total_seconds()
347+
344348
if failed:
345349
metrics_dict["total_time"] = "ERR"
350+
metrics_dict["total_elapsed_seconds"] = "ERR"
346351
else:
347352
metrics_dict["total_time"] = str(total)
353+
metrics_dict["total_elapsed_seconds"] = total.total_seconds()
354+
355+
metrics_dict.update(elapsed_seconds)
348356

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

0 commit comments

Comments
 (0)