Also use sentry for capnp exceptions (#20900)

* Also try sentry for capnp exceptions

* catch potential exceptions

* cloudlog on exception

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
albatross
Willem Melching 2021-05-15 03:06:27 +02:00 committed by GitHub
parent c08ee575f8
commit a7b3df5df8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 6 deletions

View File

@ -1,7 +1,4 @@
"""Install exception handler for process crash."""
import sys
import capnp
from selfdrive.swaglog import cloudlog
from selfdrive.version import version
@ -9,11 +6,13 @@ import sentry_sdk
from sentry_sdk.integrations.threading import ThreadingIntegration
def capture_exception(*args, **kwargs):
exc_info = sys.exc_info()
if not exc_info[0] is capnp.lib.capnp.KjException:
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
cloudlog.error("crash", exc_info=kwargs.get('exc_info', 1))
except Exception:
cloudlog.exception("sentry exception")
def bind_user(**kwargs):
sentry_sdk.set_user(kwargs)