Implement suggested changes

This commit is contained in:
Bruno Alla 2019-03-19 20:43:55 +00:00
parent b149c9933d
commit 3b8dd6e3c5
2 changed files with 10 additions and 27 deletions

View File

@ -5,6 +5,9 @@ import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.logging import LoggingIntegration
{%- if cookiecutter.use_celery == 'y' %}
from sentry_sdk.integrations.celery import CeleryIntegration
{% endif %}
{% endif -%}
from .base import * # noqa
@ -275,7 +278,14 @@ sentry_logging = LoggingIntegration(
event_level=None, # Send no events from log messages
)
{%- if cookiecutter.use_celery == 'y' %}
sentry_sdk.init(
dsn=SENTRY_DSN,
integrations=[sentry_logging, DjangoIntegration(), CeleryIntegration()],
)
{% else %}
sentry_sdk.init(dsn=SENTRY_DSN, integrations=[sentry_logging, DjangoIntegration()])
{% endif -%}
{% endif %}
# Your stuff...
# ------------------------------------------------------------------------------

View File

@ -27,33 +27,6 @@ class CeleryAppConfig(AppConfig):
def ready(self):
installed_apps = [app_config.name for app_config in apps.get_app_configs()]
app.autodiscover_tasks(lambda: installed_apps, force=True)
{%- if cookiecutter.use_sentry == 'y' %}
if hasattr(settings, "SENTRY_DSN"):
# Celery signal registration
{% if cookiecutter.use_pycharm == 'y' -%}
# Since Sentry is required in production only,
# imports might (most surely will) be wiped out
# during PyCharm code clean up started
# in other environments.
# @formatter:off
{%- endif %}
import sentry_sdk
from sentry_sdk.integrations.celery import CeleryIntegration
from sentry_sdk.integrations.logging import LoggingIntegration
{% if cookiecutter.use_pycharm == 'y' -%}
# @formatter:on
{%- endif %}
sentry_logging = LoggingIntegration(
level=settings.SENTRY_LOG_LEVEL, # Capture info and above as breadcrumbs
event_level=None, # Send no events from log messages
)
sentry_sdk.init(
dsn=settings.SENTRY_DSN,
integrations=[sentry_logging, CeleryIntegration()],
)
{%- endif %}
@app.task(bind=True)