remove sentry (#38790)

This commit is contained in:
Adeeb Shihadeh
2026-09-06 21:20:39 -07:00
committed by GitHub
parent 9d1f0d4171
commit 6bbdf8ad18
7 changed files with 10 additions and 111 deletions
+1 -3
View File
@@ -8,7 +8,6 @@ import traceback
from openpilot.cereal import log
import openpilot.cereal.messaging as messaging
import openpilot.system.sentry as sentry
from openpilot.common.utils import atomic_write
from openpilot.common.params import Params, ParamKeyFlag
from openpilot.common.text_window import TextWindow
@@ -78,7 +77,6 @@ def manager_init() -> None:
os.environ['CLEAN'] = '1'
# init logging
sentry.init(sentry.SentryProject.SELFDRIVE)
cloudlog.bind_global(dongle_id=dongle_id,
version=build_metadata.openpilot.version,
origin=build_metadata.openpilot.git_normalized_origin,
@@ -187,7 +185,7 @@ def main() -> None:
manager_thread()
except Exception:
traceback.print_exc()
sentry.capture_exception()
cloudlog.exception("crash")
finally:
manager_cleanup()
+1 -3
View File
@@ -12,7 +12,6 @@ from setproctitle import setproctitle
from openpilot.cereal import log
from opendbc.car.structs import car
import openpilot.cereal.messaging as messaging
import openpilot.system.sentry as sentry
from openpilot.common.basedir import BASEDIR
from openpilot.common.params import Params
from openpilot.common.swaglog import cloudlog
@@ -31,7 +30,6 @@ def launcher(proc: str, name: str) -> None:
# add daemon name tag to logs
cloudlog.bind(daemon=name)
sentry.set_tag("daemon", name)
# exec the process
mod.main()
@@ -40,7 +38,7 @@ def launcher(proc: str, name: str) -> None:
except Exception:
# can't install the crash handler because sys.excepthook doesn't play nice
# with threads, so catch it here.
sentry.capture_exception()
cloudlog.exception("crash")
raise
-73
View File
@@ -1,73 +0,0 @@
"""Install exception handler for process crash."""
import sentry_sdk
from enum import Enum
from sentry_sdk.integrations.threading import ThreadingIntegration
from openpilot.common.params import Params
from openpilot.system.athena.registration import is_registered_device
from openpilot.common.hardware import HARDWARE, PC
from openpilot.common.swaglog import cloudlog
from openpilot.common.version import get_build_metadata, get_version
class SentryProject(Enum):
# python project
SELFDRIVE = "https://6f3c7076c1e14b2aa10f5dde6dda0cc4@o33823.ingest.sentry.io/77924"
# native project
SELFDRIVE_NATIVE = "https://3e4b586ed21a4479ad5d85083b639bc6@o33823.ingest.sentry.io/157615"
def report_tombstone(fn: str, message: str, contents: str) -> None:
cloudlog.error({'tombstone': message})
with sentry_sdk.configure_scope() as scope:
scope.set_extra("tombstone_fn", fn)
scope.set_extra("tombstone", contents)
sentry_sdk.capture_message(message=message)
sentry_sdk.flush()
def capture_exception(*args, **kwargs) -> None:
cloudlog.error("crash", exc_info=kwargs.get('exc_info', 1))
try:
sentry_sdk.capture_exception(*args, **kwargs)
sentry_sdk.flush() # https://github.com/getsentry/sentry-python/issues/291
except Exception:
cloudlog.exception("sentry exception")
def set_tag(key: str, value: str) -> None:
sentry_sdk.set_tag(key, value)
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:
return False
env = "release" if build_metadata.tested_channel else "master"
dongle_id = Params().get("DongleId")
integrations = []
if project == SentryProject.SELFDRIVE:
integrations.append(ThreadingIntegration(propagate_hub=True))
sentry_sdk.init(project.value,
default_integrations=False,
release=get_version(),
integrations=integrations,
traces_sample_rate=1.0,
max_value_length=8192,
environment=env)
sentry_sdk.set_user({"id": dongle_id})
sentry_sdk.set_tag("dirty", build_metadata.openpilot.is_dirty)
sentry_sdk.set_tag("origin", build_metadata.openpilot.git_origin)
sentry_sdk.set_tag("branch", build_metadata.channel)
sentry_sdk.set_tag("commit", build_metadata.openpilot.git_commit)
sentry_sdk.set_tag("device", HARDWARE.get_device_type())
return True
+7 -15
View File
@@ -9,10 +9,11 @@ import time
import glob
from typing import NoReturn
import openpilot.system.sentry as sentry
from openpilot.common.hardware import PC
from openpilot.common.hardware.hw import Paths
from openpilot.common.swaglog import cloudlog
from openpilot.common.version import get_build_metadata
from openpilot.system.athena.registration import is_registered_device
MAX_SIZE = 1_000_000 * 100 # allow up to 100M
MAX_TOMBSTONE_FN_LEN = 62 # 85 - 23 ("<dongle id>/crash/")
@@ -65,22 +66,12 @@ def report_tombstone_apport(fn):
return
message = "" # One line description of the crash
contents = "" # Full file contents without coredump
path = "" # File path relative to openpilot directory
proc_maps = False
with open(fn) as f:
for line in f:
if "CoreDump" in line:
break
elif "ProcMaps" in line:
proc_maps = True
elif "ProcStatus" in line:
proc_maps = False
if not proc_maps:
contents += line
if "ExecutablePath" in line:
path = line.strip().split(': ')[-1]
@@ -112,13 +103,12 @@ def report_tombstone_apport(fn):
if not found:
crash_function = stacktrace_s[1]
# Remove arguments that can contain pointers to make sentry one-liner unique
# Remove arguments that can contain pointers from the crash summary
crash_function = " ".join(x for x in crash_function.split(' ')[1:] if not x.startswith('0x'))
crash_function = re.sub(r'\(.*?\)', '', crash_function)
contents = stacktrace + "\n\n" + contents
message = message + " - " + crash_function
sentry.report_tombstone(fn, message, contents)
cloudlog.error({'tombstone': message})
# Copy crashlog to upload folder
clean_path = path.replace('/', '_')
@@ -141,7 +131,9 @@ def report_tombstone_apport(fn):
def main() -> NoReturn:
should_report = sentry.init(sentry.SentryProject.SELFDRIVE_NATIVE)
build_metadata = get_build_metadata()
comma_remote = build_metadata.openpilot.comma_remote and "commaai" in build_metadata.openpilot.git_origin
should_report = comma_remote and is_registered_device() and not PC
# Clear apport folder on start, otherwise duplicate crashes won't register
clear_apport_folder()
-1
View File
@@ -44,7 +44,6 @@ dependencies = [
# these should be removed
"pyzmq",
"sentry-sdk",
"setproctitle",
"jeepney",
"zstandard", # this can go once we're on Python 3.14+
+1 -1
View File
@@ -22,7 +22,7 @@
- [ ] fresh install with `openpilot-test.comma.ai`
- [ ] drive on fresh install
- [ ] no submodules or LFS
- [ ] check sentry, MTBF, etc.
- [ ] check MTBF, etc.
- [ ] stress test passes in production
- [ ] publish the blog post
- [ ] `git reset --hard origin/release-mici-staging`
Generated
-15
View File
@@ -609,7 +609,6 @@ dependencies = [
{ name = "pyzmq" },
{ name = "requests" },
{ name = "scons" },
{ name = "sentry-sdk" },
{ name = "setproctitle" },
{ name = "sounddevice" },
{ name = "tqdm" },
@@ -676,7 +675,6 @@ requires-dist = [
{ name = "requests" },
{ name = "ruff", marker = "extra == 'testing'" },
{ name = "scons" },
{ name = "sentry-sdk" },
{ name = "setproctitle" },
{ name = "sounddevice" },
{ name = "teleoprtc", marker = "extra == 'submodules'", editable = "teleoprtc_repo" },
@@ -930,19 +928,6 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/8e/43/d6285848e893c19682c06e92679dc1a07d37ff7ea148747b1df681ec496c/scons-4.11.1-py3-none-any.whl", hash = "sha256:454cef364348053422696e3d2ecb4fa593c96a624f955842eaaea64f95c8d11d", size = 4123659, upload-time = "2026-08-27T04:33:12.728Z" },
]
[[package]]
name = "sentry-sdk"
version = "2.68.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "certifi" },
{ name = "urllib3" },
]
sdist = { url = "https://files.pythonhosted.org/packages/5b/94/23b7dd072acb9628907bd3f4fbf61794a7b12a9db8f33c1276f70ae5ac92/sentry_sdk-2.68.0.tar.gz", hash = "sha256:648c58e9887311a03470a41539e24bdbbf64a30ca4f5336f7e3dcc87276400b3", size = 1008854, upload-time = "2026-08-13T09:06:21.268Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/7d/9b/e2421d08956d0bc4691d995393d835e563886bff499d8fb10fdefae85a8d/sentry_sdk-2.68.0-py3-none-any.whl", hash = "sha256:538e56c2d03679d42f7c0cb5f1af73a7a510b00abc7e296c13ac49b107b713a4", size = 518670, upload-time = "2026-08-13T09:06:19.735Z" },
]
[[package]]
name = "setproctitle"
version = "1.3.7"