本文整理汇总了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))
示例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
示例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)
示例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)