Skip to content

Commit

Permalink
Filter out /admin from Sentry
Browse files Browse the repository at this point in the history
Filter out all admin pages
  • Loading branch information
KevinEtchells committed Sep 13, 2024
1 parent 2633587 commit 8f2bc4b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions django_app/redbox_app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import socket
from pathlib import Path
from urllib.parse import urlparse

import environ
import sentry_sdk
Expand Down Expand Up @@ -243,6 +244,14 @@
ALLOWED_HOSTS = [LOCALHOST, *ENVIRONMENT.hosts]

if not ENVIRONMENT.is_local:

def filter_transactions(event, hint):
url_string = event["request"]["url"]
parsed_url = urlparse(url_string)
if parsed_url.path.startswith("/admin"):
return None
return event

SENTRY_DSN = env.str("SENTRY_DSN", None)
SENTRY_ENVIRONMENT = env.str("SENTRY_ENVIRONMENT", None)
if SENTRY_DSN and SENTRY_ENVIRONMENT:
Expand All @@ -255,6 +264,7 @@
send_default_pii=False,
traces_sample_rate=1.0,
profiles_sample_rate=0.0,
before_send_transaction=filter_transactions,
)
SENTRY_REPORT_TO_ENDPOINT = URL(env.str("SENTRY_REPORT_TO_ENDPOINT", "")) or None

Expand Down

0 comments on commit 8f2bc4b

Please sign in to comment.