Beispiel #1
0
def handle_event(event: Event, context: Context) -> None:
    """Calls the handler for the given event.

    Exceptions are caught and generate both error logs and sentry issues.
    Events are not retried after an exception.
    """
    log.debug(
        "Processing event",
        event_=event,
        latest_confirmed_block=context.latest_confirmed_block,
        latest_unconfirmed_block=context.get_latest_unconfirmed_block(),
    )
    handler = HANDLERS.get(type(event))

    if handler:
        with sentry_sdk.push_scope() as sentry_scope:
            sentry_scope.set_tag("event", event.__class__.__name__)
            try:
                with metrics.collect_event_metrics(event):
                    handler(event, context)
                log.debug(
                    "Processed event",
                    num_scheduled_events=context.database.
                    scheduled_event_count(),
                )
            except Exception as ex:  # pylint: disable=broad-except
                log.error("Error during event handler",
                          handled_event=event,
                          exc_info=ex)
                sentry_sdk.capture_exception(ex)
Beispiel #2
0
def handle_event(event: Event, context: Context) -> None:
    log.debug("Processing event", event_=event)
    handler = HANDLERS.get(type(event))

    if handler:
        handler(event, context)
        log.debug("Processed event", num_scheduled_events=context.db.scheduled_event_count())