Skip to content

Commit

Permalink
Merge afe9120 into 1eee459
Browse files Browse the repository at this point in the history
  • Loading branch information
Kilo59 committed May 9, 2020
2 parents 1eee459 + afe9120 commit d8a91bf
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 53 deletions.
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-sdk = "*"
uvicorn = "*"

[requires]
Expand Down
97 changes: 52 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,12 +4,14 @@
import logging

import pydantic
import sentry_sdk
import uvicorn
from fastapi import FastAPI, Request, Response
from fastapi.middleware.cors import CORSMiddleware
from fastapi.middleware.gzip import GZipMiddleware
from fastapi.responses import JSONResponse
from scout_apm.async_.starlette import ScoutMiddleware
from sentry_sdk.integrations.asgi import SentryAsgiMiddleware

from .config import get_settings
from .data import data_source
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(SentryAsgiMiddleware)

# Enable CORS.
APP.add_middleware(
CORSMiddleware, allow_credentials=True, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"],
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
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ python-dateutil==2.8.1
python-dotenv==0.13.0
requests==2.23.0
scout-apm==2.14.1
sentry-sdk==0.14.3
six==1.14.0
starlette==0.13.2
urllib3[secure]==1.25.9 ; python_version >= '3.5'
Expand Down

0 comments on commit d8a91bf

Please sign in to comment.