Skip to content
Snippets Groups Projects
Commit 15595dc6 authored by Alexander Pace's avatar Alexander Pace
Browse files

Re-enable Sentry

parent 223ac5ff
No related branches found
No related tags found
1 merge request!195Re-enable Sentry
Pipeline #600124 passed
......@@ -4,6 +4,7 @@ import os, time, logging
from os.path import abspath, dirname, join
import socket
from django.core.exceptions import ImproperlyConfigured
from aws_xray_sdk.core.exceptions.exceptions import SegmentNotFoundException
# Set up path to root of project
BASE_DIR = abspath(join(dirname(__file__), "..", ".."))
......@@ -24,6 +25,17 @@ def get_from_env(envvar, default_value=None, fail_if_not_found=True):
def parse_envvar_bool(x):
return x.lower() in ['t', 'true', '1']
# a sentry before_send function that filters aws SegmentNotFoundException's.
# these exceptions are harmless and occur when performing management tasks
# outside of the core gracedb app. but sentry picks it up and reports it as
# an error which is ANNOYING.
def before_send(event, hint):
if "exc_info" in hint:
exc_type, exc_value, tb = hint["exc_info"]
if isinstance(exc_value, (SegmentNotFoundException,)):
return None
return event
# Maintenance mode
MAINTENANCE_MODE = False
MAINTENANCE_MODE_MESSAGE = None
......@@ -708,3 +720,5 @@ PUBLIC_PAGE_CACHING = int(get_from_env('DJANGO_PUBLIC_PAGE_CACHING',
# Define the number of results per page on the public page:
PUBLIC_PAGE_RESULTS = int(get_from_env('DJANGO_PUBLIC_PAGE_RESULTS',
fail_if_not_found=False, default_value=15))
......@@ -61,9 +61,10 @@ if sentry_dsn is not None:
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
sentry_sdk.init(
environment='test',
environment='dev',
dsn=sentry_dsn,
integrations=[DjangoIntegration()]
integrations=[DjangoIntegration()],
before_send=before_send,
)
# Turn off default admin error emails
......
......@@ -23,6 +23,24 @@ SEND_MATTERMOST_ALERTS = True
# Add testserver to ALLOWED_HOSTS
ALLOWED_HOSTS += ['testserver']
# Set up Sentry for error logging
sentry_dsn = get_from_env('DJANGO_SENTRY_DSN', fail_if_not_found=False)
if sentry_dsn is not None:
USE_SENTRY = True
# Set up Sentry
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
sentry_sdk.init(
environment='playground',
dsn=sentry_dsn,
integrations=[DjangoIntegration()],
before_send=before_send,
)
# Turn off default admin error emails
LOGGING['loggers']['django.request']['handlers'] = []
# Home page stuff
INSTANCE_TITLE = 'GraceDB Playground'
......
......@@ -53,7 +53,8 @@ if sentry_dsn is not None:
sentry_sdk.init(
environment='production',
dsn=sentry_dsn,
integrations=[DjangoIntegration()]
integrations=[DjangoIntegration()],
before_send=before_send,
)
# Turn off default admin error emails
......
......@@ -63,7 +63,8 @@ if sentry_dsn is not None:
sentry_sdk.init(
environment='test',
dsn=sentry_dsn,
integrations=[DjangoIntegration()]
integrations=[DjangoIntegration()],
before_send=before_send,
)
# Turn off default admin error emails
......
......@@ -29,7 +29,8 @@ LIST="aws_ses_access_key_id
igwn_alert_password
gracedb_ldap_keytab
egad_url
egad_api_key"
egad_api_key
django_sentry_dsn"
for SECRET in $LIST
do
......
......@@ -45,7 +45,7 @@ pymemcache==4.0.0
#pyopenssl==23.0.0
scipy==1.11.1
scitokens==1.7.4
sentry-sdk==0.7.10
sentry-sdk==1.40.1
service_identity==23.1.0
simplejson==3.19.1
six==1.16.0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment