Esempio n. 1
0
def test_span_ignored_exceptions():
    s = Span(None, None)
    s._ignore_exception(ValueError)

    with pytest.raises(ValueError):
        with s:
            raise ValueError()

    assert s.error == 0
    assert s.get_tag(errors.ERROR_MSG) is None
    assert s.get_tag(errors.ERROR_TYPE) is None
    assert s.get_tag(errors.ERROR_STACK) is None

    s = Span(None, None)
    s._ignore_exception(ValueError)

    with pytest.raises(ValueError):
        with s:
            raise ValueError()

    with pytest.raises(RuntimeError):
        with s:
            raise RuntimeError()

    assert s.error == 1
    assert s.get_tag(errors.ERROR_MSG) is not None
    assert "RuntimeError" in s.get_tag(errors.ERROR_TYPE)
    assert s.get_tag(errors.ERROR_STACK) is not None
Esempio n. 2
0
def test_span_ignored_exception_subclass():
    s = Span(None, None)
    s._ignore_exception(Exception)

    with pytest.raises(ValueError):
        with s:
            raise ValueError()

    with pytest.raises(RuntimeError):
        with s:
            raise RuntimeError()

    assert s.error == 0
    assert s.get_tag(ERROR_MSG) is None
    assert s.get_tag(ERROR_TYPE) is None
    assert s.get_tag(ERROR_STACK) is None
Esempio n. 3
0
def setup_ignored_errors(span: Span):  # pragma: no cover
    span._ignore_exception(UserBannedError)  # type: ignore
    span._ignore_exception(UserVerifiedError)  # type: ignore
    span._ignore_exception(UserUnverifiedError)  # type: ignore
    span._ignore_exception(AdminOnlyError)  # type: ignore