Beispiel #1
0
def get_exception_event():
    import sentry_sdk
    from sentry_sdk.integrations.pure_eval import PureEvalIntegration
    from sentry_sdk.integrations.executing import ExecutingIntegration

    os.environ["SENTRY_RELEASE"] = "stubbed"  # TODO get git commit?

    event = {}

    def transport(e):
        nonlocal event
        event = e

    sentry_sdk.init(
        transport=transport,
        integrations=[PureEvalIntegration(), ExecutingIntegration()],
    )
    sentry_sdk.capture_exception()

    assert event
    return event
Beispiel #2
0
def test_with_locals_disabled(sentry_init, capture_events):
    sentry_init(with_locals=False)
    events = capture_events()
    try:
        1 / 0
    except Exception:
        capture_exception()

    (event, ) = events

    assert all(
        "vars" not in frame
        for frame in event["exception"]["values"][0]["stacktrace"]["frames"])


@pytest.mark.parametrize("integrations", [[], [ExecutingIntegration()]])
def test_function_names(sentry_init, capture_events, integrations):
    sentry_init(integrations=integrations)
    events = capture_events()

    def foo():
        try:
            bar()
        except Exception:
            capture_exception()

    def bar():
        1 / 0

    foo()
Beispiel #3
0
    content, status, headers = client.post(
        reverse("read_body_and_view_exc"),
        data=b'{"hey": 42}',
        content_type="application/json",
    )

    assert status.lower() == "500 internal server error"

    (event, ) = events

    assert "data" not in event["request"]


@pytest.mark.parametrize("with_executing_integration",
                         [[], [ExecutingIntegration()]])
def test_template_exception(sentry_init, client, capture_events,
                            with_executing_integration):
    sentry_init(integrations=[DjangoIntegration()] +
                with_executing_integration)
    events = capture_events()

    content, status, headers = client.get(reverse("template_exc"))
    assert status.lower() == "500 internal server error"

    (event, ) = events
    exception = event["exception"]["values"][-1]
    assert exception["type"] == "TemplateSyntaxError"

    frames = [
        f for f in exception["stacktrace"]["frames"]
Beispiel #4
0
    THRESHOLD = 90
    MIN_PROCESSES = 1
    NUM_MEASUREMENTS = 3
    SLEEP_TIME = 5


class GITHUB_APP(DryEnv):
    ID = ''
    SECRET = ''


class FACEBOOK_APP(DryEnv):
    ID = ''
    SECRET = ''


class GOOGLE_APP(DryEnv):
    ID = ''
    SECRET = ''


snoop.install(enabled=Root.DEBUG, out=sys.__stderr__, columns=['thread'])

sentry_sdk.init(
    dsn=Root.SENTRY_DSN,
    integrations=[DjangoIntegration(), PureEvalIntegration(), ExecutingIntegration()],
    send_default_pii=True
)

populate_globals()
Beispiel #5
0
    events = capture_events()

    content, status, headers = client.post(
        reverse("read_body_and_view_exc"),
        data=b'{"hey": 42}',
        content_type="application/json",
    )

    assert status.lower() == "500 internal server error"

    (event,) = events

    assert "data" not in event["request"]


@pytest.mark.parametrize("with_executing_integration", [[], [ExecutingIntegration()]])
def test_template_exception(
    sentry_init, client, capture_events, with_executing_integration
):
    sentry_init(integrations=[DjangoIntegration()] + with_executing_integration)
    events = capture_events()

    content, status, headers = client.get(reverse("template_exc"))
    assert status.lower() == "500 internal server error"

    (event,) = events
    exception = event["exception"]["values"][-1]
    assert exception["type"] == "TemplateSyntaxError"

    frames = [
        f
Beispiel #6
0
    SLEEP_TIME = 15
    MAX_SINCE = 60 * 60


class GITHUB_APP(DryEnv):
    ID = ''
    SECRET = ''


class FACEBOOK_APP(DryEnv):
    ID = ''
    SECRET = ''


class GOOGLE_APP(DryEnv):
    ID = ''
    SECRET = ''


snoop.install(enabled=Root.DEBUG, out=sys.__stderr__, columns=['thread'])

sentry_sdk.init(dsn=Root.SENTRY_DSN,
                integrations=[
                    DjangoIntegration(),
                    PureEvalIntegration(),
                    ExecutingIntegration()
                ],
                send_default_pii=True)

populate_globals()