From 688739cb3981b779beb8431ed6208ae5e595ff02 Mon Sep 17 00:00:00 2001 From: Jelmer Draaijer Date: Fri, 28 Aug 2020 10:17:34 +0200 Subject: [PATCH] Add environment and traces_sample_rate keyword to sentry_sdk.init --- docs/settings.rst | 2 ++ .../config/settings/production.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/settings.rst b/docs/settings.rst index 949d5f35..7563f50d 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -49,6 +49,8 @@ DJANGO_AWS_S3_CUSTOM_DOMAIN AWS_S3_CUSTOM_DOMAIN n/a DJANGO_GCP_STORAGE_BUCKET_NAME GS_BUCKET_NAME n/a raises error GOOGLE_APPLICATION_CREDENTIALS n/a n/a raises error SENTRY_DSN SENTRY_DSN n/a raises error +SENTRY_ENVIRONMENT n/a n/a production +SENTRY_TRACES_SAMPLE_RATE n/a n/a 0.0 DJANGO_SENTRY_LOG_LEVEL SENTRY_LOG_LEVEL n/a logging.INFO MAILGUN_API_KEY MAILGUN_API_KEY n/a raises error MAILGUN_DOMAIN MAILGUN_SENDER_DOMAIN n/a raises error diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index 2f1b52e7..7b2776bf 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -353,13 +353,17 @@ sentry_logging = LoggingIntegration( ) {%- if cookiecutter.use_celery == 'y' %} +integrations = [sentry_logging, DjangoIntegration(), CeleryIntegration()] +{% else %} +integrations = [sentry_logging, DjangoIntegration()] +{% endif -%} + sentry_sdk.init( dsn=SENTRY_DSN, - integrations=[sentry_logging, DjangoIntegration(), CeleryIntegration()], + integrations=integrations, + environment=env("SENTRY_ENVIRONMENT", default="production"), + traces_sample_rate=env.float("SENTRY_TRACES_SAMPLE_RATE", default=0.0), ) -{% else %} -sentry_sdk.init(dsn=SENTRY_DSN, integrations=[sentry_logging, DjangoIntegration()]) -{% endif -%} {% endif %} # Your stuff... # ------------------------------------------------------------------------------