From c2406d9c29271cb5bdf5d8a659ae63ccca23f835 Mon Sep 17 00:00:00 2001 From: James <91348155+FrogAi@users.noreply.github.com> Date: Mon, 1 Dec 2025 12:00:00 -0700 Subject: [PATCH] FrogPilot Sentry reporting --- system/sentry.py | 43 ++++++++++++++++++++++++++++++--------- system/updated/updated.py | 2 ++ 2 files changed, 35 insertions(+), 10 deletions(-) mode change 100755 => 100644 system/updated/updated.py diff --git a/system/sentry.py b/system/sentry.py index 47d64ba0..df1c029a 100644 --- a/system/sentry.py +++ b/system/sentry.py @@ -1,5 +1,7 @@ """Install exception handler for process crash.""" +import os import sentry_sdk +import traceback from enum import Enum from sentry_sdk.integrations.threading import ThreadingIntegration @@ -12,9 +14,9 @@ from openpilot.system.version import get_build_metadata, get_version class SentryProject(Enum): # python project - SELFDRIVE = "https://6f3c7076c1e14b2aa10f5dde6dda0cc4@o33823.ingest.sentry.io/77924" + SELFDRIVE = os.environ.get("SENTRY_DSN", "") # native project - SELFDRIVE_NATIVE = "https://3e4b586ed21a4479ad5d85083b639bc6@o33823.ingest.sentry.io/157615" + SELFDRIVE_NATIVE = os.environ.get("SENTRY_DSN", "") def report_tombstone(fn: str, message: str, contents: str) -> None: @@ -28,6 +30,14 @@ def report_tombstone(fn: str, message: str, contents: str) -> None: def capture_exception(*args, **kwargs) -> None: + exc_text = traceback.format_exc() + + errors_to_ignore = [ + ] + + if any(error in exc_text for error in errors_to_ignore): + return + cloudlog.error("crash", exc_info=kwargs.get('exc_info', 1)) try: @@ -44,12 +54,24 @@ def set_tag(key: str, value: str) -> None: def init(project: SentryProject) -> bool: build_metadata = get_build_metadata() # forks like to mess with this, so double check - comma_remote = build_metadata.openpilot.comma_remote and "commaai" in build_metadata.openpilot.git_origin - if not comma_remote or not is_registered_device() or PC: + FrogPilot = "frogai" in build_metadata.openpilot.git_origin.lower() + if not FrogPilot or PC: return False - env = "release" if build_metadata.tested_channel else "master" - dongle_id = Params().get("DongleId") + short_branch = build_metadata.channel + + if short_branch in ["COMMA", "HEAD"]: + return + elif short_branch == "FrogPilot-Development": + env = "Development" + elif build_metadata.release_channel: + env = "Release" + elif short_branch == "FrogPilot-Testing": + env = "Testing" + elif build_metadata.tested_channel: + env = "Staging" + else: + env = short_branch integrations = [] if project == SentryProject.SELFDRIVE: @@ -63,11 +85,12 @@ def init(project: SentryProject) -> bool: max_value_length=8192, environment=env) - sentry_sdk.set_user({"id": dongle_id}) - sentry_sdk.set_tag("dirty", build_metadata.openpilot.is_dirty) + params = Params() + + sentry_sdk.set_user({"id": params.get("DongleId")}) sentry_sdk.set_tag("origin", build_metadata.openpilot.git_origin) - sentry_sdk.set_tag("branch", build_metadata.channel) + sentry_sdk.set_tag("branch", short_branch) sentry_sdk.set_tag("commit", build_metadata.openpilot.git_commit) - sentry_sdk.set_tag("device", HARDWARE.get_device_type()) + sentry_sdk.set_tag("updated", params.get("Updated")) return True diff --git a/system/updated/updated.py b/system/updated/updated.py old mode 100755 new mode 100644 index 47f385c3..110fe849 --- a/system/updated/updated.py +++ b/system/updated/updated.py @@ -11,6 +11,7 @@ import time import threading from collections import defaultdict from pathlib import Path +from zoneinfo import ZoneInfo from openpilot.common.basedir import BASEDIR from openpilot.common.params import Params @@ -411,6 +412,7 @@ class Updater: cloudlog.info("finalize success!") # FrogPilot variables + self.params.put("Updated", datetime.datetime.now().astimezone(ZoneInfo("America/Phoenix")).strftime("%B %d, %Y - %I:%M%p")) def main() -> None: params = Params()