Trial running Sentry in Admin

This will capture and send various events to Sentry:

- Any unhandled exceptions.
- Any logger.error calls.
- Some request traces.

The latter are severely limited to avoid going over the free tier
limits for Sentry, and to avoid excess effort on our end.
This commit is contained in:
Ben Thorner
2021-12-30 14:05:43 +00:00
parent 50c3c3e10c
commit 5ae8acb8aa
3 changed files with 21 additions and 0 deletions

View File

@@ -1,7 +1,20 @@
import os
import sentry_sdk
from flask import Flask
from sentry_sdk.integrations.flask import FlaskIntegration
from app import create_app
sentry_sdk.init(
dsn=os.environ['SENTRY_DSN'],
integrations=[FlaskIntegration()],
environment=os.environ['NOTIFY_ENVIRONMENT'],
attach_stacktrace=True,
traces_sample_rate=0.00005 # avoid exceeding rate limits in Production
)
sentry_sdk.set_level('error') # only record error logs or exceptions
application = Flask('app')
create_app(application)