Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Commit d8291b9

Browse files
committed
Sentry integration
1 parent 90cabf5 commit d8291b9

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

app.py

+11
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,26 @@
33
from starlette.staticfiles import StaticFiles
44
from starlette.responses import HTMLResponse
55
from starlette.templating import Jinja2Templates
6+
from sentry_sdk.integrations.asgi import SentryAsgiMiddleware
7+
import sentry_sdk
68
import uvicorn
79

810

911
config = Config()
1012
DEBUG = config("DEBUG", cast=bool, default=False)
13+
SENTRY_DSN = config("DEBUG", cast=str, default="")
14+
15+
if SENTRY_DSN:
16+
sentry_sdk.init(dsn=SENTRY_DSN)
17+
1118

1219
templates = Jinja2Templates(directory="templates")
1320

1421
app = Starlette(debug=DEBUG)
22+
23+
if SENTRY_DSN:
24+
app.add_middleware(SentryAsgiMiddleware)
25+
1526
app.mount("/static", StaticFiles(directory="statics"), name="static")
1627

1728

requirements.base

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ aiofiles==0.4.*
1010
jinja2==2.*
1111
starlette==0.12.*
1212
uvicorn==0.9.*
13+
sentry-sdk==0.12.*
1314

1415
# Testing (For consistency we still want to install these to production tho.)
15-
black==19.*
16+
black
1617
pytest==5.*
1718
requests==2.*

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ py==1.8.0
1919
pyparsing==2.4.2
2020
pytest==5.2.0
2121
requests==2.22.0
22+
sentry-sdk==0.12.3
2223
six==1.12.0
2324
starlette==0.12.9
2425
toml==0.10.0

scripts/install

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ if ! [ -f .env ] ; then
1313
fi
1414

1515
if [ "$1" = "--update" ]; then
16+
rm -f requirements.txt
1617
${BIN_PATH}pip install -U -r requirements.base
17-
scripts/freeze
18+
${BIN_PATH}pip freeze > requirements.txt
1819
else
1920
${BIN_PATH}pip install -U -r requirements.txt
2021
fi

0 commit comments

Comments
 (0)