Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Sentry (#24)
* add sentry-asgi

* sentry middleware
  • Loading branch information
Kilo59 authored May 9, 2020
commit 7fe38b9b7304b25d7edee2a7d923d1b25db0c60d
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pydantic = {extras = ["dotenv"],version = "*"}
python-dateutil = "*"
requests = "*"
scout-apm = "*"
sentry-asgi = "*"
uvicorn = "*"

[requires]
Expand Down
103 changes: 58 additions & 45 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class _Settings(BaseSettings):
local_redis_url: AnyUrl = None
# Scout APM
scout_name: str = None
# Sentry
sentry_dsn: str = None


@functools.lru_cache()
Expand Down
10 changes: 10 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import logging

import pydantic
import sentry_asgi
import sentry_sdk
import uvicorn
from fastapi import FastAPI, Request, Response
from fastapi.middleware.cors import CORSMiddleware
Expand All @@ -23,6 +25,9 @@

SETTINGS = get_settings()

if SETTINGS.sentry_dsn: # pragma: no cover
sentry_sdk.init(dsn=SETTINGS.sentry_dsn)

APP = FastAPI(
title="Coronavirus Tracker",
description=(
Expand All @@ -47,6 +52,11 @@
else:
LOGGER.debug("No SCOUT_NAME config")

# Sentry Error Tracking
if SETTINGS.sentry_dsn: # pragma: no cover
LOGGER.info("Adding Sentry middleware")
APP.add_middleware(sentry_asgi.SentryMiddleware)

# Enable CORS.
APP.add_middleware(
CORSMiddleware,
Expand Down
16 changes: 8 additions & 8 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-i https://pypi.org/simple
appdirs==1.4.3
astroid==2.4.0
astroid==2.4.1
async-asgi-testclient==1.4.4
async-generator==1.10
asyncmock==0.4.2
Expand All @@ -13,8 +13,8 @@ click==7.1.2
coverage==5.1
coveralls==2.0.0
docopt==0.6.2
gitdb==4.0.4
gitpython==3.1.1
gitdb==4.0.5
gitpython==3.1.2
idna==2.9
importlib-metadata==1.6.0 ; python_version < '3.8'
invoke==1.4.1
Expand All @@ -29,17 +29,17 @@ pathspec==0.8.0
pbr==5.4.5
pluggy==0.13.1
py==1.8.1
pylint==2.5.0
pylint==2.5.2
pyparsing==2.4.7
pytest-asyncio==0.11.0
pytest-asyncio==0.12.0
pytest-cov==2.8.1
pytest==5.4.1
pytest==5.4.2
pyyaml==5.3.1
regex==2020.4.4
regex==2020.5.7
requests==2.23.0
responses==0.10.14
six==1.14.0
smmap==3.0.2
smmap==3.0.4
stevedore==1.32.0
toml==0.10.0
typed-ast==1.4.1
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ python-dateutil==2.8.1
python-dotenv==0.13.0
requests==2.23.0
scout-apm==2.14.1
sentry-asgi==0.2.0
sentry-sdk==0.14.3
six==1.14.0
starlette==0.13.2
urllib3[secure]==1.25.9 ; python_version >= '3.5'
Expand Down