summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosip Sokcevic <sokcevic@google.com>2023-05-15 12:54:10 -0700
committerLUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-05-15 22:21:23 +0000
commit2ad5d508740a0bf3a4fe13bd27525b57da683a68 (patch)
tree4573ef1b80d92e5985be499a825b44e7eec207e6
parentacb9523eaab5a0aead71b85b5d17ac9b715b513c (diff)
downloadgit-repo-2ad5d508740a0bf3a4fe13bd27525b57da683a68.tar.gz
[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 <gavinmak@google.com> Tested-by: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Josip Sokcevic <sokcevic@google.com>
-rw-r--r--git_trace2_event_log.py6
1 files 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):
65 if env is None: 65 if env is None:
66 env = os.environ 66 env = os.environ
67 67
68 now = datetime.datetime.utcnow() 68 self.start = datetime.datetime.utcnow()
69 69
70 # Save both our sid component and the complete sid. 70 # Save both our sid component and the complete sid.
71 # We use our sid component (self._sid) as the unique filename prefix and 71 # We use our sid component (self._sid) as the unique filename prefix and
72 # the full sid (self._full_sid) in the log itself. 72 # the full sid (self._full_sid) in the log itself.
73 self._sid = "repo-%s-P%08x" % ( 73 self._sid = "repo-%s-P%08x" % (
74 now.strftime("%Y%m%dT%H%M%SZ"), 74 self.start.strftime("%Y%m%dT%H%M%SZ"),
75 os.getpid(), 75 os.getpid(),
76 ) 76 )
77 parent_sid = env.get(KEY) 77 parent_sid = env.get(KEY)
@@ -136,6 +136,8 @@ class EventLog(object):
136 if result is None: 136 if result is None:
137 result = 0 137 result = 0
138 exit_event["code"] = result 138 exit_event["code"] = result
139 time_delta = datetime.datetime.utcnow() - self.start
140 exit_event["t_abs"] = time_delta.total_seconds()
139 self._log.append(exit_event) 141 self._log.append(exit_event)
140 142
141 def CommandEvent(self, name, subcommands): 143 def CommandEvent(self, name, subcommands):