Merge pull request #4114 from alphagov/trial-sentry-180766893

Trial running Sentry in a Flask app
This commit is contained in:
Ben Thorner
2021-12-31 11:31:53 +00:00
committed by GitHub
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)

View File

@@ -41,3 +41,5 @@ cryptography<3.4 # pyup: ignore
# version 0.10.0 introduced exceptions when workers crashed due to deprecating lower case `prometheus_multiproc_dir`.
prometheus-client>=0.9.0,!=0.10.0
gds-metrics==0.2.4
sentry-sdk[flask]

View File

@@ -18,6 +18,7 @@ blinker==1.4
# via
# -r requirements.in
# gds-metrics
# sentry-sdk
boto3==1.17.84
# via notifications-utils
botocore==1.20.84
@@ -31,6 +32,7 @@ certifi==2021.5.30
# via
# pyproj
# requests
# sentry-sdk
cffi==1.14.5
# via cryptography
chardet==4.0.0
@@ -65,6 +67,7 @@ flask==1.1.2
# flask-wtf
# gds-metrics
# notifications-utils
# sentry-sdk
flask-login==0.5.0
# via -r requirements.in
flask-redis==0.4.0
@@ -198,6 +201,8 @@ s3transfer==0.4.2
# via
# awscli
# boto3
sentry-sdk[flask]==1.5.1
# via -r requirements.in
shapely==1.7.1
# via
# -r requirements.in
@@ -220,6 +225,7 @@ urllib3==1.26.5
# via
# botocore
# requests
# sentry-sdk
webencodings==0.5.1
# via bleach
werkzeug==2.0.2