Skip to content

Commit

Permalink
Ignore Pyro5 address recovery errors in sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
koirikivi committed May 14, 2024
1 parent f2ea1ca commit 45dc0ab
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions bridge_node/bridge/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import warnings

import sentry_sdk
from Pyro5.errors import CommunicationError, SecurityError

logger = logging.getLogger(__name__)

Expand All @@ -11,7 +12,21 @@ def init_sentry(dsn):
warnings.warn("Sentry DSN not set, Sentry disabled", stacklevel=2)
return

def before_send(event, hint):
if "exc_info" in hint:
exc_value = hint["exc_info"][1]

# TODO: Address recovered from Pyro5 handshake is sometimes not valid. Not sure why this would happen --
# it needs to be investigated, but for now let's just ignore
if isinstance(exc_value, CommunicationError | SecurityError):
if "does not match any of the allowed addresses" in str(exc_value):
logger.info("Ignoring Pyro5 error: %s", exc_value)
return None

return event

logger.info("Initializing Sentry")
sentry_sdk.init(
dsn=dsn,
before_send=before_send,
)

0 comments on commit 45dc0ab

Please sign in to comment.