FrogPilot Sentry reporting
This commit is contained in:
+33
-10
@@ -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
|
||||
|
||||
Executable → Regular
+2
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user