From 2ad5d508740a0bf3a4fe13bd27525b57da683a68 Mon Sep 17 00:00:00 2001 From: Josip Sokcevic Date: Mon, 15 May 2023 12:54:10 -0700 Subject: [PATCH] [trace2] Add absolute time on trace2 exit events Change-Id: I58aff46bd4ff4ba79286a7f1226e19eb568c34c5 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/373954 Reviewed-by: Gavin Mak Tested-by: Josip Sokcevic Commit-Queue: Josip Sokcevic --- git_trace2_event_log.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/git_trace2_event_log.py b/git_trace2_event_log.py index d90e9039..820cbac0 100644 --- a/git_trace2_event_log.py +++ b/git_trace2_event_log.py @@ -65,13 +65,13 @@ class EventLog(object): if env is None: env = os.environ - now = datetime.datetime.utcnow() + self.start = datetime.datetime.utcnow() # Save both our sid component and the complete sid. # We use our sid component (self._sid) as the unique filename prefix and # the full sid (self._full_sid) in the log itself. self._sid = "repo-%s-P%08x" % ( - now.strftime("%Y%m%dT%H%M%SZ"), + self.start.strftime("%Y%m%dT%H%M%SZ"), os.getpid(), ) parent_sid = env.get(KEY) @@ -136,6 +136,8 @@ class EventLog(object): if result is None: result = 0 exit_event["code"] = result + time_delta = datetime.datetime.utcnow() - self.start + exit_event["t_abs"] = time_delta.total_seconds() self._log.append(exit_event) def CommandEvent(self, name, subcommands):