From 3b6c604d8550eb247d6830bcd521ebc96b187956 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 3 Sep 2019 08:53:08 +0100 Subject: [PATCH] Add sentry middleware for ASGI --- Pipfile | 1 + Pipfile.lock | 9 ++++++++- actioner/web/__init__.py | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Pipfile b/Pipfile index 1d5e862..461f147 100644 --- a/Pipfile +++ b/Pipfile @@ -35,3 +35,4 @@ python-dateutil = "==2.8.0" starlette = "==0.12.9" uvicorn = "==0.8.6" starlette-auth-toolkit = "==0.5.0" +sentry-asgi = "==0.2.0" diff --git a/Pipfile.lock b/Pipfile.lock index 4a7c10c..8a1d845 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "0e4b536511730008f5acfed1fc87a219976efc3ff233583edb362befe854f00e" + "sha256": "1b18f00a22630052a4574e27d066214fbf4dee101c5c918d787e7850c3d28141" }, "pipfile-spec": 6, "requires": { @@ -108,6 +108,13 @@ ], "version": "==2.22.0" }, + "sentry-asgi": { + "hashes": [ + "sha256:0fc35fc6da9c16c0353f087c29fcfcd694b767bd1a77a2e768f519618eb3defd" + ], + "index": "pypi", + "version": "==0.2.0" + }, "sentry-sdk": { "hashes": [ "sha256:528f936118679e9a52dacb96bfefe20acb5d63e0797856c64a582cc3c2bc1f9e", diff --git a/actioner/web/__init__.py b/actioner/web/__init__.py index 7d63fd7..810caf5 100644 --- a/actioner/web/__init__.py +++ b/actioner/web/__init__.py @@ -1,6 +1,7 @@ import os import uvicorn +from sentry_asgi import SentryMiddleware from starlette.applications import Starlette from starlette.authentication import SimpleUser, requires # or a custom user model from starlette.middleware.authentication import AuthenticationMiddleware @@ -29,6 +30,7 @@ def get_server(): ] ) app.add_middleware(AuthenticationMiddleware, backend=BasicAuth()) + app.add_middleware(SentryMiddleware) return app