diff options
author | Bryan Newbold <bnewbold@archive.org> | 2020-10-23 00:06:50 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@archive.org> | 2020-10-23 00:06:50 -0700 |
commit | 3161319d0fe3feafe2b5fed48b9383680f9f0547 (patch) | |
tree | e0bfda2fe6bec3786743e90418b8e295e0419682 /fatcat_scholar/web.py | |
parent | d52f5c1d5de7193ef367c812bc741ebd52655bdd (diff) | |
download | fatcat-scholar-3161319d0fe3feafe2b5fed48b9383680f9f0547.tar.gz fatcat-scholar-3161319d0fe3feafe2b5fed48b9383680f9f0547.zip |
basic test for issue-db pipeline
Diffstat (limited to 'fatcat_scholar/web.py')
-rw-r--r-- | fatcat_scholar/web.py | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/fatcat_scholar/web.py b/fatcat_scholar/web.py index f266e08..79b4f30 100644 --- a/fatcat_scholar/web.py +++ b/fatcat_scholar/web.py @@ -13,6 +13,7 @@ from fastapi.staticfiles import StaticFiles from fastapi.responses import PlainTextResponse import sentry_sdk from sentry_sdk.integrations.asgi import SentryAsgiMiddleware +from starlette_prometheus import metrics, PrometheusMiddleware from fatcat_scholar.config import settings, GIT_REVISION from fatcat_scholar.hacks import Jinja2Templates, parse_accept_lang @@ -26,16 +27,6 @@ I18N_LANG_OPTIONS = I18N_LANG_TRANSLATIONS + [ settings.I18N_LANG_DEFAULT, ] -# note the middleware also installed at the end of this file -if settings.SENTRY_DSN: - logger.info("Sentry integration enabled") - sentry_sdk.init( - dsn=settings.SENTRY_DSN, - environment=settings.SCHOLAR_ENV, - max_breadcrumbs=10, - release=GIT_REVISION, - ) - class LangPrefix: """ @@ -261,5 +252,19 @@ async def robots_txt(response_class: Any = PlainTextResponse) -> Any: else: return PlainTextResponse(ROBOTS_DISALLOW) -# add sentry middleware -app = SentryAsgiMiddleware(app) + +# configure middleware + +if settings.SENTRY_DSN: + logger.info("Sentry integration enabled") + sentry_sdk.init( + dsn=settings.SENTRY_DSN, + environment=settings.SCHOLAR_ENV, + max_breadcrumbs=10, + release=GIT_REVISION, + ) + app.add_middleware(SentryAsgiMiddleware) + +if settings.ENABLE_PROMETHEUS: + app.add_middleware(PrometheusMiddleware) + app.add_route("/prometheus/", metrics) |