コード例 #1
0
ファイル: sentry.py プロジェクト: tstalka/commcare-hq
def _rate_limit_exc(exc_info):
    exc_type, exc_value, tb = exc_info
    rate_limit_key = _get_rate_limit_key(exc_info)
    if not rate_limit_key:
        return False

    datadog_counter('commcare.sentry.errors.rate_limited',
                    tags=['service:{}'.format(rate_limit_key)])
    if is_pg_cancelled_query_exception(exc_value):
        datadog_counter('hq_custom.postgres.standby_query_canellations')
    exponential_backoff_key = '{}_down'.format(rate_limit_key)
    return is_rate_limited(exponential_backoff_key)
コード例 #2
0
    def should_capture(self, exc_info):
        ex_value = exc_info[1]
        capture = getattr(ex_value, 'sentry_capture', True)
        if not capture:
            return False

        if not super(HQSentryClient, self).should_capture(exc_info):
            return False

        rate_limit_key = _get_rate_limit_key(exc_info)
        if rate_limit_key:
            datadog_counter('commcare.sentry.errors.rate_limited',
                            tags=['service:{}'.format(rate_limit_key)])
            exponential_backoff_key = '{}_down'.format(rate_limit_key)
            return not is_rate_limited(exponential_backoff_key)
        return True
コード例 #3
0
    def should_capture(self, exc_info):
        ex_value = exc_info[1]
        capture = getattr(ex_value, 'sentry_capture', True)
        if not capture:
            return False

        if not super(HQSentryClient, self).should_capture(exc_info):
            return False

        rate_limit_key = _get_rate_limit_key(exc_info)
        if rate_limit_key:
            datadog_counter('commcare.sentry.errors.rate_limited', tags=[
                'service:{}'.format(rate_limit_key)
            ])
            exponential_backoff_key = '{}_down'.format(rate_limit_key)
            return not is_rate_limited(exponential_backoff_key)
        return True
コード例 #4
0
ファイル: sentry.py プロジェクト: solleks/commcare-hq
def _rate_limit_exc(exc_info):
    exc_type, exc_value, tb = exc_info
    rate_limit_key = _get_rate_limit_key(exc_info)
    if not rate_limit_key:
        return False

    try:
        rate_limit_key = subtype_error(tb, rate_limit_key)
    except Exception:
        logger.exception("Error while subtyping rate limited error")

    metrics_counter('commcare.sentry.errors.rate_limited',
                    tags={'service': rate_limit_key})
    if is_pg_cancelled_query_exception(exc_value):
        metrics_counter('commcare.postgres.standby_query_canellations')
    exponential_backoff_key = '{}_down'.format(rate_limit_key)
    return is_rate_limited(exponential_backoff_key)
コード例 #5
0
ファイル: adapter.py プロジェクト: dimagi/commcare-hq
 def handle_exception(self, doc, exception):
     from corehq.util.cache_utils import is_rate_limited
     ex_clss = exception.__class__
     key = '{domain}.{table}.{ex_mod}.{ex_name}'.format(
         domain=self.config.domain,
         table=self.config.table_id,
         ex_mod=ex_clss.__module__,
         ex_name=ex_clss.__name__
     )
     if not is_rate_limited(key):
         notify_exception(
             None,
             'unexpected error saving UCR doc',
             details={
                 'domain': self.config.domain,
                 'doc_id': doc.get('_id', '<unknown>'),
                 'table': '{} ({})'.format(self.config.display_name, self.config._id)
             }
         )
コード例 #6
0
 def handle_exception(self, doc, exception):
     from corehq.util.cache_utils import is_rate_limited
     ex_clss = exception.__class__
     key = '{domain}.{table}.{ex_mod}.{ex_name}'.format(
         domain=self.config.domain,
         table=self.config.table_id,
         ex_mod=ex_clss.__module__,
         ex_name=ex_clss.__name__
     )
     if not is_rate_limited(key):
         notify_exception(
             None,
             'unexpected error saving UCR doc: {}'.format(exception),
             details={
                 'domain': self.config.domain,
                 'doc_id': doc.get('_id', '<unknown>'),
                 'table': '{} ({})'.format(self.config.display_name, self.config._id)
             }
         )
コード例 #7
0
ファイル: sentry.py プロジェクト: marissahrrsn/commcare-hq
    def should_capture(self, exc_info):
        ex_value = exc_info[1]
        capture = getattr(ex_value, 'sentry_capture', True)
        if not capture:
            return False

        if not super(HQSentryClient, self).should_capture(exc_info):
            return False

        rate_limit_key = _get_rate_limit_key(exc_info)
        if rate_limit_key:
            datadog_counter('commcare.sentry.errors.rate_limited', tags=[
                'service:{}'.format(rate_limit_key)
            ])
            if is_pg_cancelled_query_exception(ex_value):
                datadog_counter('hq_custom.postgres.standby_query_canellations')
            exponential_backoff_key = '{}_down'.format(rate_limit_key)
            return not is_rate_limited(exponential_backoff_key)
        return True