コード例 #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
コード例 #2
0
def init_sentry(app):
    plugin_packages = {
        ep.module_name.split('.')[0]
        for ep in iter_entry_points('indico.plugins')
    }
    ignore_logger('indico.flask')
    sentry_sdk.init(
        dsn=config.SENTRY_DSN,
        release=indico.__version__,
        send_default_pii=True,
        attach_stacktrace=True,
        in_app_include=({'indico'} | plugin_packages),
        integrations=[
            PureEvalIntegration(),
            RedisIntegration(),
            FlaskIntegration(transaction_style='url'),
            LoggingIntegration(
                event_level=getattr(logging, config.SENTRY_LOGGING_LEVEL))
        ],
        _experiments={'record_sql_params': True})

    app.before_request(_set_request_info)
コード例 #3
0
ファイル: simple_settings.py プロジェクト: pwwang/futurecoder
    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()
コード例 #4
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()
コード例 #5
0
import pytest

from sentry_sdk import capture_exception
from sentry_sdk.integrations.pure_eval import PureEvalIntegration


@pytest.mark.parametrize("integrations", [[], [PureEvalIntegration()]])
def test_with_locals_enabled(sentry_init, capture_events, integrations):
    sentry_init(with_locals=True, integrations=integrations)
    events = capture_events()

    def foo():
        foo.d = {1: 2}
        print(foo.d[1] / 0)

    try:
        foo()
    except Exception:
        capture_exception()

    (event, ) = events

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

    frame_vars = event["exception"]["values"][0]["stacktrace"]["frames"][-1][
        "vars"]

    if integrations:
        assert sorted(frame_vars.keys()) == ["foo", "foo.d", "foo.d[1]"]