Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FFT-69 Set up sentry performance monitoring #528

Merged
merged 6 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.ci
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ CACHE_ENDPOINT=redis://redis:6379
AUTHBROKER_CLIENT_ID=
AUTHBROKER_CLIENT_SECRET=
AUTHBROKER_URL=
SENTRY_ENVIRONMENT=ci
SENTRY_DSN=
25 changes: 25 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@

import dj_database_url
import environ
import sentry_sdk
from dbt_copilot_python.database import database_url_from_env
from dbt_copilot_python.utility import is_copilot
from django.urls import reverse_lazy
from django_log_formatter_asim import ASIMFormatter
from django_log_formatter_ecs import ECSFormatter
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.redis import RedisIntegration


BASE_DIR = Path(__file__).resolve().parent.parent.parent
Expand Down Expand Up @@ -384,3 +387,25 @@ def FILTERS_VERBOSE_LOOKUPS():
},
},
}


# Sentry
# https://docs.sentry.io/platforms/python/guides/django/
SENTRY_ENVIRONMENT = env.str("SENTRY_ENVIRONMENT", None)
SENTRY_DSN = env.str("SENTRY_DSN", None)

# Configure sentry if a DSN is set
if SENTRY_DSN:
# TODO: AWS Prefix needs to be removed once migration is complete.
sentry_environment = (
f"aws-{SENTRY_ENVIRONMENT}" if is_copilot() else SENTRY_ENVIRONMENT
)
sentry_sdk.init(
SamDudley marked this conversation as resolved.
Show resolved Hide resolved
dsn=SENTRY_DSN,
environment=sentry_environment,
release=GIT_COMMIT,
integrations=[DjangoIntegration(), RedisIntegration()],
enable_tracing=env.bool("SENTRY_ENABLE_TRACING", False),
traces_sample_rate=env.float("SENTRY_TRACES_SAMPLE_RATE", 0.0),
send_default_pii=True,
)
6 changes: 0 additions & 6 deletions config/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@
# Set async file uploading
ASYNC_FILE_UPLOAD = True

sentry_sdk.init(
os.environ.get("SENTRY_DSN"),
environment=os.environ.get("SENTR Y_ENVIRONMENT"),
integrations=[DjangoIntegration()],
)

# HSTS (https://man.uktrade.io/docs/procedures/1st-go-live.html)
SECURE_HSTS_SECONDS = 3600
SECURE_HSTS_PRELOAD = True
Expand Down
6 changes: 0 additions & 6 deletions config/settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@
# Set async file uploading
ASYNC_FILE_UPLOAD = True

sentry_sdk.init(
os.environ.get("SENTRY_DSN"),
environment=os.environ.get("SENTRY_ENVIRONMENT"),
integrations=[DjangoIntegration()],
)

# Django staff SSO user migration process requries the following
MIGRATE_EMAIL_USER_ON_LOGIN = True

Expand Down