本文整理匯總了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)