From 8b5b0ae3415e1ea44a1eecb6e70cec16b0fb1565 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Wed, 26 Jan 2022 11:44:10 -0800 Subject: [PATCH] sentry improvements (#23627) * sentry: filter out unregistered devices and PC * add daemon name --- selfdrive/athena/registration.py | 5 +++++ selfdrive/manager/process.py | 3 ++- selfdrive/sentry.py | 10 ++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/selfdrive/athena/registration.py b/selfdrive/athena/registration.py index f19540eb8..b0b9dd2e6 100755 --- a/selfdrive/athena/registration.py +++ b/selfdrive/athena/registration.py @@ -17,6 +17,11 @@ from selfdrive.swaglog import cloudlog UNREGISTERED_DONGLE_ID = "UnregisteredDevice" +def is_registered_device() -> bool: + dongle = Params().get("DongleId", encoding='utf-8') + return dongle not in (None, UNREGISTERED_DONGLE_ID) + + def register(show_spinner=False) -> str: params = Params() params.put("SubscriberInfo", HARDWARE.get_subscriber_info()) diff --git a/selfdrive/manager/process.py b/selfdrive/manager/process.py index 5165d6da7..ebdd2a90b 100644 --- a/selfdrive/manager/process.py +++ b/selfdrive/manager/process.py @@ -34,8 +34,9 @@ def launcher(proc: str, name: str) -> None: # create new context since we forked messaging.context = messaging.Context() - # add daemon name to cloudlog ctx + # add daemon name tag to logs cloudlog.bind(daemon=name) + sentry.set_tag("daemon", name) # exec the process getattr(mod, 'main')() diff --git a/selfdrive/sentry.py b/selfdrive/sentry.py index db763bf16..5f22bf18e 100644 --- a/selfdrive/sentry.py +++ b/selfdrive/sentry.py @@ -4,7 +4,8 @@ from enum import Enum from sentry_sdk.integrations.threading import ThreadingIntegration from common.params import Params -from selfdrive.hardware import HARDWARE +from selfdrive.athena.registration import is_registered_device +from selfdrive.hardware import HARDWARE, PC from selfdrive.swaglog import cloudlog from selfdrive.version import get_branch, get_commit, get_origin, get_version, \ is_comma_remote, is_dirty, is_tested_branch @@ -37,9 +38,14 @@ def capture_exception(*args, **kwargs) -> None: cloudlog.exception("sentry exception") +def set_tag(key: str, value: str) -> None: + sentry_sdk.set_tag(key, value) + + def init(project: SentryProject) -> None: # forks like to mess with this, so double check - if not (is_comma_remote() and "commaai" in get_origin(default="")): + comma_remote = is_comma_remote() and "commaai" in get_origin(default="") + if not comma_remote or not is_registered_device() or PC: return env = "release" if is_tested_branch() else "master"