当前位置: 首页>>代码示例>>Python>>正文


Python sentry_sdk.init方法代码示例

本文整理汇总了Python中sentry_sdk.init方法的典型用法代码示例。如果您正苦于以下问题:Python sentry_sdk.init方法的具体用法?Python sentry_sdk.init怎么用?Python sentry_sdk.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sentry_sdk的用法示例。


在下文中一共展示了sentry_sdk.init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: sentry_init

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import init [as 别名]
def sentry_init(obs_apiurl=None, tags=None):
    try:
        import sentry_sdk
    except ImportError:
        sentry_init.client = sentry_client_dummy()
        return sentry_sdk_dummy()

    sentry_init.client = sentry_sdk.init(
        conf.config.get('sentry_sdk.dsn'),
        environment=conf.config.get('sentry_sdk.environment'),
        release=VERSION)

    with sentry_sdk.configure_scope() as scope:
        scope.set_tag('osc', core.__version__)

        if obs_apiurl:
            scope.set_tag('obs_apiurl', obs_apiurl)
            scope.user = {'username': conf.get_apiurl_usr(obs_apiurl)}

        if tags:
            for key, value in tags.items():
                scope.set_tag(key, value)

    return sentry_sdk 
开发者ID:openSUSE,项目名称:openSUSE-release-tools,代码行数:26,代码来源:sentry.py

示例2: post_setup

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import init [as 别名]
def post_setup(cls):
        """Post setup configuration.

        This is the place where you can configure settings that require other
        settings to be loaded.
        """
        super().post_setup()

        # The DJANGO_SENTRY_DSN environment variable should be set to activate
        # sentry for an environment
        if cls.SENTRY_DSN is not None:
            sentry_sdk.init(
                dsn=cls.SENTRY_DSN,
                environment=cls.ENVIRONMENT,
                release=cls.RELEASE,
                integrations=[DjangoIntegration()],
            )
            with sentry_sdk.configure_scope() as scope:
                scope.set_extra("application", "backend") 
开发者ID:openfun,项目名称:marsha,代码行数:21,代码来源:settings.py

示例3: setup_logging

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import init [as 别名]
def setup_logging():
    """
    Setup the correct logging verbosity and file handlers.
    We also add a logger for Sentry in case it has been set in the environment.
    Sentry allows us to centrally collect error logging during development.
    """
    if os.environ.get("SENTRY_SDK_URL"):
        import sentry_sdk
        sentry_sdk.init(os.environ.get("SENTRY_SDK_URL"))

    # Configuration for which we need access to both settings and logging singletons should happen here
    logging.verbosity = settings.config.getint("general", "log_verbosity")
    logging.logger.setLevel(settings.config.get("general", "log_level"))

    # Log Handlers
    log_file = settings.config.get("general", "log_file")

    if os.path.exists(os.path.dirname(log_file)):
        logging.add_file_handler(log_file)
    else:
        logging.logger.warning(
            'log directory for log file %s does not exist, check your settings! Only logging to stdout', log_file) 
开发者ID:NVISO-BE,项目名称:ee-outliers,代码行数:24,代码来源:outliers.py

示例4: init_sentry

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import init [as 别名]
def init_sentry():
    distribution = get_distribution("MozPhab")

    sentry_logging = LoggingIntegration(
        level=logging.INFO,
        event_level=None,
        # The default event_level is logging.ERROR, which will report any
        # "logging.error(...)" call to Sentry.  However, we respond to
        # incorrect usage with "logging.error(...)" messages, which we don't
        # want to report to Sentry.
    )
    sentry_sdk.init(
        dsn="https://e8a2a97b86c7472f9308186547aebfa2@sentry.prod.mozaws.net/502",
        integrations=[sentry_logging],
        release=distribution.version,
    ) 
开发者ID:mozilla-conduit,项目名称:review,代码行数:18,代码来源:sentry.py

示例5: post_setup

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import init [as 别名]
def post_setup(cls):
        """Post setup configuration.
        This is the place where you can configure settings that require other
        settings to be loaded.
        """
        super().post_setup()

        # The SENTRY_DSN setting should be available to activate sentry for an environment
        if cls.SENTRY_DSN is not None:
            sentry_sdk.init(
                dsn=cls.SENTRY_DSN,
                environment=cls.ENVIRONMENT,
                release=cls.RELEASE,
                integrations=[DjangoIntegration()],
            )
            with sentry_sdk.configure_scope() as scope:
                scope.set_extra("application", "backend") 
开发者ID:openfun,项目名称:richie,代码行数:19,代码来源:settings.py

示例6: register

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import init [as 别名]
def register(app: Flask):
    if 'SENTRY_IO' not in app.config:
        return

    def merged_configuration(conf: dict) -> dict:
        defaults = {
            'environment': app.config['ENVIRONMENT'],
            'debug': app.config['DEBUG']
        }
        return {**defaults, **conf}

    for (k, grp) in groupby(app.config['SENTRY_IO']):
        mdl = 'sentry_sdk.integrations.' + k.lower()
        integrations = map(
            lambda key: getattr(import_module(mdl), key.title() + 'Integration')(), grp
        )
        sentry_sdk.init(
            dsn=app.config['SENTRY_IO'][k]['dsn'],
            integrations=list(integrations),
            **merged_configuration(
                app.config['SENTRY_IO'][k]['configuration']
                if 'configuration' in app.config['SENTRY_IO'][k] else {}
            )
        ) 
开发者ID:kkamkou,项目名称:gitmostwanted.com,代码行数:26,代码来源:sentry.py

示例7: set_raven_client

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import init [as 别名]
def set_raven_client() -> bool:
    from polyaxon import pkg
    from polyaxon.env_vars.keys import POLYAXON_KEYS_SERVICE
    from polyaxon.managers.cli import CliConfigManager

    cli_config = CliConfigManager.get_config()
    if cli_config and cli_config.log_handler and cli_config.log_handler.decoded_dsn:
        import sentry_sdk

        sentry_sdk.init(
            dsn=cli_config.log_handler.decoded_dsn,
            release=pkg.VERSION,
            environment=cli_config.log_handler.environment,
            server_name=os.environ.get(POLYAXON_KEYS_SERVICE, None),
        )
        return True

    return False 
开发者ID:polyaxon,项目名称:polyaxon,代码行数:20,代码来源:sentry.py

示例8: init_sentry

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import init [as 别名]
def init_sentry(app):
    """Init sentry if DSN *and* environment are provided."""
    dsn = app.config['SENTRY_DSN']
    env = app.config['SENTRY_ENVIRONMENT']

    if dsn is None and env is None:
        return

    if None in (dsn, env):
        raise ValueError("You need to specify both DSN and environment "
                         "to use Sentry.")

    sentry_sdk.init(
        dsn=dsn,
        integrations=[FlaskIntegration()],
        environment=env,
    ) 
开发者ID:amiv-eth,项目名称:amivapi,代码行数:19,代码来源:bootstrap.py

示例9: create_app

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import init [as 别名]
def create_app(config_name):
    """Factory of Creating app
    @param:
        config_name - all configurations of app
    """
    sentry_sdk.init(
        dsn="",
        integrations=[FlaskIntegration()])
    application = Flask(__name__)
    application.config.from_object(config[config_name])
    config[config_name].init_app(application)

    csrf = CSRFProtect()

    from .image.model import image_db
    from .image.views import image as image_blueprint
    from .image.apis import blueprint as image_api_blueprint

    csrf.init_app(application)
    image_db.init_app(application)
    application.register_blueprint(image_blueprint)
    application.register_blueprint(image_api_blueprint, url_prefix='/api/v1')

    return application 
开发者ID:leollon,项目名称:yet-another-image-bed,代码行数:26,代码来源:__init__.py

示例10: wrapSentry

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import init [as 别名]
def wrapSentry(mainFunc):
    if not getDebug():
        import traceback
        try:
            import sentry_sdk
            from sentry_sdk import capture_exception
            sentry_sdk.init("https://1cc0c8280fa54361920e75f014add9fe@sentry.io/1406946")
            try:
                mainFunc()
            except Exception as e:
                traceback.print_exc()
                capture_exception(e)
        except Exception as e:
            traceback.print_exc()
            mainFunc()
    else:
        mainFunc()

# Generate a SSL certificate using module M2Crypto,  an existing one will
# be overwritten . 
开发者ID:HelloZeroNet,项目名称:ZeroNet-kivy,代码行数:22,代码来源:platform_android.py

示例11: main

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import init [as 别名]
def main():
    """Entry point for poetry script."""
    sentry_sdk.init(
        SENTRY_URL,
        release=Repo().head.object.hexsha,
        integrations=[AioHttpIntegration()],
    )
    bot.run(BOT_TOKEN) 
开发者ID:CyberDiscovery,项目名称:cyberdisc-bot,代码行数:10,代码来源:__init__.py

示例12: __init__

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import init [as 别名]
def __init__(self, prefix, description=None, testing=False, **options):
        super(Avrae, self).__init__(prefix, help_command=help_command, description=description, **options)
        self.testing = testing
        self.state = "init"
        self.credentials = Credentials()
        if config.TESTING:
            self.mclient = motor.motor_asyncio.AsyncIOMotorClient(self.credentials.test_mongo_url)
        else:
            self.mclient = motor.motor_asyncio.AsyncIOMotorClient(config.MONGO_URL)
        self.mdb = self.mclient[config.MONGODB_DB_NAME]
        self.rdb = self.loop.run_until_complete(self.setup_rdb())
        self.prefixes = dict()
        self.muted = set()
        self.cluster_id = 0

        # sentry
        if config.SENTRY_DSN is not None:
            release = None
            if config.GIT_COMMIT_SHA:
                release = f"avrae-bot@{config.GIT_COMMIT_SHA}"
            sentry_sdk.init(dsn=config.SENTRY_DSN, environment=config.ENVIRONMENT.title(), release=release)

        # ddb entitlements
        if config.TESTING and config.DDB_AUTH_SERVICE_URL is None:
            self.ddb = BeyondClientBase()
        else:
            self.ddb = BeyondClient(self.loop)

        # launchdarkly
        self.ldclient = AsyncLaunchDarklyClient(self.loop, sdk_key=config.LAUNCHDARKLY_SDK_KEY) 
开发者ID:avrae,项目名称:avrae,代码行数:32,代码来源:dbot.py

示例13: register_extensions

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import init [as 别名]
def register_extensions(app):
    db.init_app(app)
    executor.init_app(app)
    basic_auth.init_app(app)

    @app.before_request
    def enable_form_raw_cache():
        # Workaround to allow unparsed request body to be be read from cache
        # This is required to validate a signature on webhooks
        # This MUST go before Sentry integration as sentry triggers form parsing
        if not config.IS_TEST and (
                request.path.startswith('/api/v1/slack/') or request.path.startswith('/api/v1/poli_payments_webhook/')):
            if request.content_length > 1024 * 1024:  # 1mb
                # Payload too large
                return make_response(jsonify({'message': 'Payload too large'})), 413
            request.get_data(parse_form_data=False, cache=True)

    # limiter.init_app(app)

    CORS(app, resources={r"/api/*": {"origins": "*"}})

    celery_app.conf.update(app.config)
    if not config.IS_TEST:
        sentry_sdk.init(app.config['SENTRY_SERVER_DSN'], integrations=[FlaskIntegration()], release=config.VERSION)

    print('celery joined on {} at {}'.format(
        app.config['REDIS_URL'], datetime.utcnow())) 
开发者ID:teamsempo,项目名称:SempoBlockchain,代码行数:29,代码来源:__init__.py

示例14: test_atexit

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import init [as 别名]
def test_atexit(tmpdir, monkeypatch, num_messages):
    app = tmpdir.join("app.py")
    app.write(
        dedent(
            """
    import time
    from sentry_sdk import init, transport, capture_message

    def send_event(self, event):
        time.sleep(0.1)
        print(event["message"])

    transport.HttpTransport._send_event = send_event
    init("http://foobar@localhost/123", shutdown_timeout={num_messages})

    for _ in range({num_messages}):
        capture_message("HI")
    """.format(
                num_messages=num_messages
            )
        )
    )

    start = time.time()
    output = subprocess.check_output([sys.executable, str(app)])
    end = time.time()

    # Each message takes at least 0.1 seconds to process
    assert int(end - start) >= num_messages / 10

    assert output.count(b"HI") == num_messages 
开发者ID:getsentry,项目名称:sentry-python,代码行数:33,代码来源:test_client.py

示例15: test_broken_mapping

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import init [as 别名]
def test_broken_mapping(sentry_init, capture_events):
    sentry_init()
    events = capture_events()

    class C(Mapping):
        def broken(self, *args, **kwargs):
            raise Exception("broken")

        __getitem__ = broken
        __setitem__ = broken
        __delitem__ = broken
        __iter__ = broken
        __len__ = broken

        def __repr__(self):
            return "broken"

    try:
        a = C()  # noqa
        1 / 0
    except Exception:
        capture_exception()

    (event,) = events
    assert (
        event["exception"]["values"][0]["stacktrace"]["frames"][0]["vars"]["a"]
        == "<failed to serialize, use init(debug=True) to see error logs>"
    ) 
开发者ID:getsentry,项目名称:sentry-python,代码行数:30,代码来源:test_client.py


注:本文中的sentry_sdk.init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。