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

ci: allow sentry to be configured per environment #821

Merged
merged 1 commit into from
Sep 11, 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
3 changes: 3 additions & 0 deletions .github/workflows/reusable-push-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ jobs:
CSRF_TRUSTED_ORIGINS: ${{ vars.CSRF_TRUSTED_ORIGINS }}
DJANGO_LOG_LEVEL: ${{ vars.DJANGO_LOG_LEVEL }}
SENTRY_DSN_WORKAROUND: ${{ vars.SENTRY_DSN_WORKAROUND }}
TRACES_SAMPLE_RATE: ${{vars.TRACES_SAMPLE_RATE}}
PROFILES_SAMPLE_RATE: ${{vars.PROFILES_SAMPLE_RATE}}
ENABLE_TRACING: ${{vars.ENABLE_TRACING}}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
CATALOGUE_TOKEN: ${{ secrets.CATALOGUE_TOKEN }}
IMAGE_PATH: ${{ steps.image-path.outputs.image_path }}
Expand Down
10 changes: 7 additions & 3 deletions core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,23 @@

# Sentry Configuration
if not TESTING:
ENABLE_TRACING = os.environ.get("ENABLE_TRACING") in TRUTHY_VALUES
TRACES_SAMPLE_RATE = float(os.environ.get("TRACES_SAMPLE_RATE", 0.0))
PROFILES_SAMPLE_RATE = float(os.environ.get("PROFILES_SAMPLE_RATE", 0.0))

sentry_sdk.init(
dsn=os.environ.get(
"SENTRY_DSN_WORKAROUND"
), # Datahub overwrites with this variable unless it is renamed,
# causing Sentry to tag issues with the incorrect environment
enable_tracing=True,
enable_tracing=ENABLE_TRACING,
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
traces_sample_rate=1.0,
traces_sample_rate=TRACES_SAMPLE_RATE,
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
profiles_sample_rate=PROFILES_SAMPLE_RATE,
environment=ENV or "local",
)

Expand Down
6 changes: 6 additions & 0 deletions deployments/templates/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ spec:
value: "$AZURE_AUTHORITY"
- name: CSRF_TRUSTED_ORIGINS
value: "${CSRF_TRUSTED_ORIGINS}"
- name: ENABLE_TRACING
value: "${ENABLE_TRACING}"
- name: TRACES_SAMPLE_RATE
value: "${TRACES_SAMPLE_RATE}"
- name: PROFILES_SAMPLE_RATE
value: "${PROFILES_SAMPLE_RATE}"
- name: SECRET_KEY
valueFrom:
secretKeyRef:
Expand Down