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


Python celery.CeleryIntegration方法代码示例

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


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

示例1: test_sentry_initialized_from_envvar

# 需要导入模块: from sentry_sdk.integrations import celery [as 别名]
# 或者: from sentry_sdk.integrations.celery import CeleryIntegration [as 别名]
def test_sentry_initialized_from_envvar(self):
        """ The DSN for Sentry comes from config. """
        fake_dsn = 'https://hex-code@sentry.io/123446'

        with mock.patch.dict('os.environ', {'RAVEN_DSN': fake_dsn}):
            with mock.patch.object(settings.sentry_sdk, 'init') as init_sentry:
                self._fresh_settings_load()
        init_sentry.assert_called_once_with(
            fake_dsn,
            integrations=[mock.ANY, mock.ANY],  # Django & Celery, checked separately
            send_default_pii=True,
        )
        integrations = init_sentry.call_args_list[0][1]['integrations']

        self.assertTrue(isinstance(integrations[0], DjangoIntegration))
        self.assertTrue(isinstance(integrations[1], CeleryIntegration)) 
开发者ID:DavidCain,项目名称:mitoc-trips,代码行数:18,代码来源:test_settings.py

示例2: init_celery

# 需要导入模块: from sentry_sdk.integrations import celery [as 别名]
# 或者: from sentry_sdk.integrations.celery import CeleryIntegration [as 别名]
def init_celery(sentry_init):
    def inner(propagate_traces=True, **kwargs):
        sentry_init(
            integrations=[CeleryIntegration(propagate_traces=propagate_traces)],
            **kwargs
        )
        celery = Celery(__name__)
        if VERSION < (4,):
            celery.conf.CELERY_ALWAYS_EAGER = True
        else:
            celery.conf.task_always_eager = True
        return celery

    return inner 
开发者ID:getsentry,项目名称:sentry-python,代码行数:16,代码来源:test_celery.py

示例3: __init__

# 需要导入模块: from sentry_sdk.integrations import celery [as 别名]
# 或者: from sentry_sdk.integrations.celery import CeleryIntegration [as 别名]
def __init__(self):
        """
        Initialize the Sentry SDK.
        """
        ignore_logger("airflow.task")
        ignore_logger("airflow.jobs.backfill_job.BackfillJob")
        executor_name = conf.get("core", "EXECUTOR")

        sentry_flask = FlaskIntegration()

        # LoggingIntegration is set by default.
        integrations = [sentry_flask]

        if executor_name == "CeleryExecutor":
            from sentry_sdk.integrations.celery import CeleryIntegration

            sentry_celery = CeleryIntegration()
            integrations.append(sentry_celery)

        dsn = conf.get("sentry", "sentry_dsn")
        if dsn:
            init(dsn=dsn, integrations=integrations)
        else:
            # Setting up Sentry using environment variables.
            log.debug("Defaulting to SENTRY_DSN in environment.")
            init(integrations=integrations) 
开发者ID:apache,项目名称:airflow,代码行数:28,代码来源:sentry.py

示例4: configure_sentry

# 需要导入模块: from sentry_sdk.integrations import celery [as 别名]
# 或者: from sentry_sdk.integrations.celery import CeleryIntegration [as 别名]
def configure_sentry(
    runner_type: str,
    celery_integration: bool = False,
    flask_integration: bool = False,
    sqlalchemy_integration: bool = False,
) -> None:
    logger.debug(
        f"Setup sentry for {runner_type}: "
        f"celery_integration={celery_integration}, "
        f"flask_integration={flask_integration}, "
        f"sqlalchemy_integration={sqlalchemy_integration}"
    )

    secret_key = getenv("SENTRY_SECRET")
    if not secret_key:
        return

    # so that we don't have to have sentry sdk installed locally
    import sentry_sdk

    integrations = []

    if celery_integration:
        # https://docs.sentry.io/platforms/python/celery/
        from sentry_sdk.integrations.celery import CeleryIntegration

        integrations.append(CeleryIntegration())

    if flask_integration:
        # https://docs.sentry.io/platforms/python/flask/
        from sentry_sdk.integrations.flask import FlaskIntegration

        integrations.append(FlaskIntegration())

    if sqlalchemy_integration:
        # https://docs.sentry.io/platforms/python/sqlalchemy/
        from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration

        integrations.append(SqlalchemyIntegration())

    sentry_sdk.init(
        secret_key, integrations=integrations, environment=getenv("DEPLOYMENT"),
    )
    with sentry_sdk.configure_scope() as scope:
        scope.set_tag("runner-type", runner_type) 
开发者ID:packit-service,项目名称:packit-service,代码行数:47,代码来源:sentry_integration.py


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