From 94b3f2d22a538fdd36a9c9a446c91efe9d82f69b Mon Sep 17 00:00:00 2001 From: Greg Hogan Date: Fri, 2 Feb 2024 23:10:04 -0800 Subject: [PATCH] logging: make swaglog context match in python and c (#31288) * logging: make swaglog context match in python and c * add git context to athenad old-commit-hash: d0a1fa636a9bf2f6137c4a61b27fa29f690864f6 --- common/swaglog.cc | 9 +++++++++ selfdrive/athena/manage_athenad.py | 11 +++++++++-- selfdrive/manager/manager.py | 3 +++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/common/swaglog.cc b/common/swaglog.cc index 873836b725..7864a6355a 100644 --- a/common/swaglog.cc +++ b/common/swaglog.cc @@ -41,6 +41,15 @@ public: if (char* dongle_id = getenv("DONGLE_ID")) { ctx_j["dongle_id"] = dongle_id; } + if (char* git_origin = getenv("GIT_ORIGIN")) { + ctx_j["origin"] = git_origin; + } + if (char* git_branch = getenv("GIT_BRANCH")) { + ctx_j["branch"] = git_branch; + } + if (char* git_commit = getenv("GIT_COMMIT")) { + ctx_j["commit"] = git_commit; + } if (char* daemon_name = getenv("MANAGER_DAEMON")) { ctx_j["daemon"] = daemon_name; } diff --git a/selfdrive/athena/manage_athenad.py b/selfdrive/athena/manage_athenad.py index 2a4a12e559..486e426911 100755 --- a/selfdrive/athena/manage_athenad.py +++ b/selfdrive/athena/manage_athenad.py @@ -6,7 +6,8 @@ from multiprocessing import Process from openpilot.common.params import Params from openpilot.selfdrive.manager.process import launcher from openpilot.common.swaglog import cloudlog -from openpilot.system.version import get_version, is_dirty +from openpilot.system.hardware import HARDWARE +from openpilot.system.version import get_version, get_normalized_origin, get_short_branch, get_commit, is_dirty ATHENA_MGR_PID_PARAM = "AthenadPid" @@ -14,7 +15,13 @@ ATHENA_MGR_PID_PARAM = "AthenadPid" def main(): params = Params() dongle_id = params.get("DongleId").decode('utf-8') - cloudlog.bind_global(dongle_id=dongle_id, version=get_version(), dirty=is_dirty()) + cloudlog.bind_global(dongle_id=dongle_id, + version=get_version(), + origin=get_normalized_origin(), + branch=get_short_branch(), + commit=get_commit(), + dirty=is_dirty(), + device=HARDWARE.get_device_type()) try: while 1: diff --git a/selfdrive/manager/manager.py b/selfdrive/manager/manager.py index 7733acec93..ddc1200cbc 100755 --- a/selfdrive/manager/manager.py +++ b/selfdrive/manager/manager.py @@ -79,6 +79,9 @@ def manager_init() -> None: serial = params.get("HardwareSerial") raise Exception(f"Registration failed for device {serial}") os.environ['DONGLE_ID'] = dongle_id # Needed for swaglog + os.environ['GIT_ORIGIN'] = get_normalized_origin() # Needed for swaglog + os.environ['GIT_BRANCH'] = get_short_branch() # Needed for swaglog + os.environ['GIT_COMMIT'] = get_commit() # Needed for swaglog if not is_dirty(): os.environ['CLEAN'] = '1'