openpilot is an open source driver assistance system. openpilot performs the functions of Automated Lane Centering and Adaptive Cruise Control for over 200 supported car makes and models.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.2 KiB

5 years ago
"""Install exception handler for process crash."""
import os
import sys
import capnp
from selfdrive.hardware import PC
5 years ago
from selfdrive.swaglog import cloudlog
from selfdrive.version import version
5 years ago
if os.getenv("NOLOG") or os.getenv("NOCRASH") or PC:
def capture_exception(*args, **kwargs):
5 years ago
pass
5 years ago
def bind_user(**kwargs):
pass
5 years ago
def bind_extra(**kwargs):
pass
5 years ago
else:
import sentry_sdk
from sentry_sdk.integrations.threading import ThreadingIntegration
5 years ago
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
5 years ago
cloudlog.error("crash", exc_info=kwargs.get('exc_info', 1))
def bind_user(**kwargs):
sentry_sdk.set_user(kwargs)
5 years ago
def bind_extra(**kwargs):
for k, v in kwargs.items():
sentry_sdk.set_tag(k, v)
5 years ago
sentry_sdk.init("https://a8dc76b5bfb34908a601d67e2aa8bcf9@o33823.ingest.sentry.io/77924",
default_integrations=False, integrations=[ThreadingIntegration(propagate_hub=True)],
release=version)