diff --git a/poetry.lock b/poetry.lock index 8cad374..cab45d1 100644 --- a/poetry.lock +++ b/poetry.lock @@ -669,6 +669,32 @@ optional = false python-versions = "*" version = "0.2.0" +[[package]] +category = "main" +description = "Python client for Sentry (https://getsentry.com)" +name = "sentry-sdk" +optional = false +python-versions = "*" +version = "0.15.1" + +[package.dependencies] +certifi = "*" +urllib3 = ">=1.10.0" + +[package.extras] +aiohttp = ["aiohttp (>=3.5)"] +beam = ["beam (>=2.12)"] +bottle = ["bottle (>=0.12.13)"] +celery = ["celery (>=3)"] +django = ["django (>=1.8)"] +falcon = ["falcon (>=1.4)"] +flask = ["flask (>=0.11)", "blinker (>=1.1)"] +pyspark = ["pyspark (>=2.4.4)"] +rq = ["rq (>=0.6)"] +sanic = ["sanic (>=0.8)"] +sqlalchemy = ["sqlalchemy (>=1.2)"] +tornado = ["tornado (>=5)"] + [[package]] category = "main" description = "Python 2 and 3 compatibility utilities" @@ -768,7 +794,7 @@ docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"] testing = ["jaraco.itertools", "func-timeout"] [metadata] -content-hash = "479ed51fef7eb2990163f57ff4255887cd559deea9bb631fd8e3ca81e6939715" +content-hash = "6b207d452b10de2399c4c49118da997dda6ed1bb0437963c3f415ecd3d806fe5" python-versions = "^3.7" [metadata.files] @@ -1112,6 +1138,10 @@ requests = [ {file = "ruamel.yaml.clib-0.2.0-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:be018933c2f4ee7de55e7bd7d0d801b3dfb09d21dad0cce8a97995fd3e44be30"}, {file = "ruamel.yaml.clib-0.2.0.tar.gz", hash = "sha256:b66832ea8077d9b3f6e311c4a53d06273db5dc2db6e8a908550f3c14d67e718c"}, ] +sentry-sdk = [ + {file = "sentry-sdk-0.15.1.tar.gz", hash = "sha256:3ac0c430761b3cb7682ce612151d829f8644bb3830d4e530c75b02ceb745ff49"}, + {file = "sentry_sdk-0.15.1-py2.py3-none-any.whl", hash = "sha256:06825c15a78934e78941ea25910db71314c891608a46492fc32c15902c6b2119"}, +] six = [ {file = "six-1.14.0-py2.py3-none-any.whl", hash = "sha256:8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c"}, {file = "six-1.14.0.tar.gz", hash = "sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a"}, diff --git a/pyproject.toml b/pyproject.toml index 71b5efc..bdc34a9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,7 @@ psycopg2-binary = "^2.8.5" gunicorn = "^20.0.4" python-dotenv = "^0.12.0" django = ">=3.0.7" +sentry-sdk = "^0.15.1" [tool.poetry.dev-dependencies] factory-boy = "^2.12.0" diff --git a/src/newsreader/conf/production.py b/src/newsreader/conf/production.py index b5c766a..7e883f7 100644 --- a/src/newsreader/conf/production.py +++ b/src/newsreader/conf/production.py @@ -49,3 +49,16 @@ TEMPLATES = [ AXES_HANDLER = "axes.handlers.database.AxesDatabaseHandler" REGISTRATION_OPEN = False + +# Optionally use sentry integration +try: + from sentry_sdk import init as sentry_init + from sentry_sdk.integrations.django import CeleryIntegration, DjangoIntegration + + sentry_init( + dsn=os.environ.get("SENTRY_DSN"), + integrations=[DjangoIntegration(), CeleryIntegration()], + send_default_pii=False, + ) +except ImportError: + pass