disable sentry for devices without a dongle ID (#20729)

* disable sentry for devices without a dongle ID

* import pc

* unused
old-commit-hash: 47ad2a485f
commatwo_master
Adeeb Shihadeh 4 years ago committed by GitHub
parent ab900874db
commit 4c461b3f7f
  1. 1
      selfdrive/athena/athenad.py
  2. 40
      selfdrive/crash.py
  3. 5
      selfdrive/manager/manager.py

@ -412,6 +412,7 @@ def backoff(retries):
def main(): def main():
params = Params() params = Params()
dongle_id = params.get("DongleId", encoding='utf-8') dongle_id = params.get("DongleId", encoding='utf-8')
crash.init()
crash.bind_user(id=dongle_id) crash.bind_user(id=dongle_id)
crash.bind_extra(dirty=dirty, origin=origin, branch=branch, commit=commit, crash.bind_extra(dirty=dirty, origin=origin, branch=branch, commit=commit,
device=HARDWARE.get_device_type()) device=HARDWARE.get_device_type())

@ -1,40 +1,28 @@
"""Install exception handler for process crash.""" """Install exception handler for process crash."""
import os
import sys import sys
import capnp import capnp
from selfdrive.hardware import PC
from selfdrive.swaglog import cloudlog from selfdrive.swaglog import cloudlog
from selfdrive.version import version from selfdrive.version import version
if os.getenv("NOLOG") or os.getenv("NOCRASH") or PC: import sentry_sdk
def capture_exception(*args, **kwargs): from sentry_sdk.integrations.threading import ThreadingIntegration
pass
def bind_user(**kwargs): def capture_exception(*args, **kwargs):
pass exc_info = sys.exc_info()
if not exc_info[0] is capnp.lib.capnp.KjException:
sentry_sdk.capture_exception(*args, **kwargs)
sentry_sdk.flush() # https://github.com/getsentry/sentry-python/issues/291
cloudlog.error("crash", exc_info=kwargs.get('exc_info', 1))
def bind_extra(**kwargs): def bind_user(**kwargs):
pass sentry_sdk.set_user(kwargs)
else: def bind_extra(**kwargs):
import sentry_sdk for k, v in kwargs.items():
from sentry_sdk.integrations.threading import ThreadingIntegration sentry_sdk.set_tag(k, v)
def capture_exception(*args, **kwargs):
exc_info = sys.exc_info()
if not exc_info[0] is capnp.lib.capnp.KjException:
sentry_sdk.capture_exception(*args, **kwargs)
sentry_sdk.flush() # https://github.com/getsentry/sentry-python/issues/291
cloudlog.error("crash", exc_info=kwargs.get('exc_info', 1))
def bind_user(**kwargs):
sentry_sdk.set_user(kwargs)
def bind_extra(**kwargs):
for k, v in kwargs.items():
sentry_sdk.set_tag(k, v)
def init():
sentry_sdk.init("https://a8dc76b5bfb34908a601d67e2aa8bcf9@o33823.ingest.sentry.io/77924", sentry_sdk.init("https://a8dc76b5bfb34908a601d67e2aa8bcf9@o33823.ingest.sentry.io/77924",
default_integrations=False, integrations=[ThreadingIntegration(propagate_hub=True)], default_integrations=False, integrations=[ThreadingIntegration(propagate_hub=True)],
release=version) release=version)

@ -12,7 +12,7 @@ from common.basedir import BASEDIR
from common.params import Params from common.params import Params
from common.text_window import TextWindow from common.text_window import TextWindow
from selfdrive.boardd.set_time import set_time from selfdrive.boardd.set_time import set_time
from selfdrive.hardware import HARDWARE, TICI from selfdrive.hardware import HARDWARE, PC, TICI
from selfdrive.manager.helpers import unblock_stdout from selfdrive.manager.helpers import unblock_stdout
from selfdrive.manager.process import ensure_running from selfdrive.manager.process import ensure_running
from selfdrive.manager.process_config import managed_processes from selfdrive.manager.process_config import managed_processes
@ -83,6 +83,9 @@ def manager_init():
cloudlog.bind_global(dongle_id=dongle_id, version=version, dirty=dirty, cloudlog.bind_global(dongle_id=dongle_id, version=version, dirty=dirty,
device=HARDWARE.get_device_type()) device=HARDWARE.get_device_type())
if not (dongle_id is None or os.getenv("NOLOG") or os.getenv("NOCRASH") or PC):
crash.init()
crash.bind_user(id=dongle_id) crash.bind_user(id=dongle_id)
crash.bind_extra(dirty=dirty, origin=origin, branch=branch, commit=commit, crash.bind_extra(dirty=dirty, origin=origin, branch=branch, commit=commit,
device=HARDWARE.get_device_type()) device=HARDWARE.get_device_type())

Loading…
Cancel
Save