trace: Save trace2 sid in REPO_TRACE file

git-trace2 events contain additional information what git is doing under
the hood, and repo doesn't have visibility into.

Instead of relying on timestamp information to match REPO_TRACE with
git-trace2 events, add SID information into REPO_TRACE.

Change-Id: I37672a3face81858072c7a3ce34ca3379199dab5
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/410280
Tested-by: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
This commit is contained in:
Josip Sokcevic 2024-02-21 11:04:03 -08:00 committed by LUCI
parent fec8cd6704
commit 8896b68926

11
main.py
View File

@ -270,10 +270,14 @@ class _Repo:
self._PrintHelp(short=True) self._PrintHelp(short=True)
return 1 return 1
run = lambda: self._RunLong(name, gopts, argv) or 0 git_trace2_event_log = EventLog()
run = (
lambda: self._RunLong(name, gopts, argv, git_trace2_event_log) or 0
)
with Trace( with Trace(
"starting new command: %s", "starting new command: %s [sid=%s]",
", ".join([name] + argv), ", ".join([name] + argv),
git_trace2_event_log.full_sid,
first_trace=True, first_trace=True,
): ):
if gopts.trace_python: if gopts.trace_python:
@ -290,12 +294,11 @@ class _Repo:
result = run() result = run()
return result return result
def _RunLong(self, name, gopts, argv): def _RunLong(self, name, gopts, argv, git_trace2_event_log):
"""Execute the (longer running) requested subcommand.""" """Execute the (longer running) requested subcommand."""
result = 0 result = 0
SetDefaultColoring(gopts.color) SetDefaultColoring(gopts.color)
git_trace2_event_log = EventLog()
outer_client = RepoClient(self.repodir) outer_client = RepoClient(self.repodir)
repo_client = outer_client repo_client = outer_client
if gopts.submanifest_path: if gopts.submanifest_path: