diff --git a/poetry.lock b/poetry.lock index 678bac4..cf78f6d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -349,6 +349,36 @@ idna = {version = "*", optional = true, markers = "extra == \"idna2008\""} [package.extras] idna2008 = ["idna"] +[[package]] +name = "sentry-sdk" +version = "1.5.10" +description = "Python client for Sentry (https://sentry.io)" +category = "main" +optional = false +python-versions = "*" + +[package.dependencies] +certifi = "*" +urllib3 = ">=1.10.0" + +[package.extras] +aiohttp = ["aiohttp (>=3.5)"] +beam = ["apache-beam (>=2.12)"] +bottle = ["bottle (>=0.12.13)"] +celery = ["celery (>=3)"] +chalice = ["chalice (>=1.16.0)"] +django = ["django (>=1.8)"] +falcon = ["falcon (>=1.4)"] +flask = ["flask (>=0.11)", "blinker (>=1.1)"] +httpx = ["httpx (>=0.16.0)"] +pure_eval = ["pure-eval", "executing", "asttokens"] +pyspark = ["pyspark (>=2.4.4)"] +quart = ["quart (>=0.16.1)", "blinker (>=1.1)"] +rq = ["rq (>=0.6)"] +sanic = ["sanic (>=0.8)"] +sqlalchemy = ["sqlalchemy (>=1.2)"] +tornado = ["tornado (>=5)"] + [[package]] name = "six" version = "1.16.0" @@ -458,7 +488,7 @@ testing = ["coverage (>=4)", "coverage-enable-subprocess (>=1)", "flaky (>=3)", [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "ffd93f8b1f721e72d72a7368fdd17a52c3083afaaaf85777c663f3162199a99e" +content-hash = "9faf19232e7ce4a3e03a8c5d1c5bd3ce3e1a096b095b9ec528016d7919143e99" [metadata.files] aioredis = [ @@ -704,6 +734,10 @@ rfc3986 = [ {file = "rfc3986-1.5.0-py2.py3-none-any.whl", hash = "sha256:a86d6e1f5b1dc238b218b012df0aa79409667bb209e58da56d0b94704e712a97"}, {file = "rfc3986-1.5.0.tar.gz", hash = "sha256:270aaf10d87d0d4e095063c65bf3ddbc6ee3d0b226328ce21e036f946e421835"}, ] +sentry-sdk = [ + {file = "sentry-sdk-1.5.10.tar.gz", hash = "sha256:0a9eb20a84f4c17c08c57488d59fdad18669db71ebecb28fb0721423a33535f9"}, + {file = "sentry_sdk-1.5.10-py2.py3-none-any.whl", hash = "sha256:972c8fe9318a415b5cf35f687f568321472ef94b36806407c370ce9c88a67f2e"}, +] six = [ {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, diff --git a/pyproject.toml b/pyproject.toml index d11fff1..0fc6c7b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,6 +14,7 @@ uvicorn = {extras = ["standart"], version = "^0.17.1"} httpx = "^0.22.0" uvloop = "^0.16.0" gunicorn = "^20.1.0" +sentry-sdk = "^1.5.10" [tool.poetry.dev-dependencies] pre-commit = "^2.17.0" diff --git a/src/app/services.py b/src/app/services.py index 9560b0d..c5526d0 100644 --- a/src/app/services.py +++ b/src/app/services.py @@ -35,7 +35,7 @@ DEFAULT_RANKING_RULES = [ ] -async def update_books(ctx) -> bool: +async def update_books(ctx) -> bool: # NOSONAR loop = asyncio.get_event_loop() meili = get_meilisearch_client() @@ -61,7 +61,7 @@ async def update_books(ctx) -> bool: return True -async def update_authors(ctx) -> bool: +async def update_authors(ctx) -> bool: # NOSONAR loop = asyncio.get_event_loop() meili = get_meilisearch_client() @@ -98,14 +98,14 @@ async def update_authors(ctx) -> bool: index.update_searchable_attributes(["first_name", "last_name", "middle_name"]) index.update_filterable_attributes(["author_langs", "translator_langs"]) - index.update_ranking_rules([*DEFAULT_RANKING_RULES, "books_count:desc"]) + index.update_ranking_rules([*DEFAULT_RANKING_RULES, "books_count:desc"]) # NOSONAR await postgres.close() return True -async def update_sequences(ctx) -> bool: +async def update_sequences(ctx) -> bool: # NOSONAR loop = asyncio.get_event_loop() meili = get_meilisearch_client() @@ -143,7 +143,7 @@ async def update_sequences(ctx) -> bool: return True -async def update_genres(ctx) -> bool: +async def update_genres(ctx) -> bool: # NOSONAR loop = asyncio.get_event_loop() meili = get_meilisearch_client() @@ -183,7 +183,7 @@ async def update_genres(ctx) -> bool: return True -async def update(ctx: dict, *args, **kwargs) -> bool: +async def update(ctx: dict, *args, **kwargs) -> bool: # NOSONAR arq_pool: ArqRedis = ctx["arc_pool"] await arq_pool.enqueue_job("update_books") diff --git a/src/core/app.py b/src/core/app.py index 44656bf..c74f25d 100644 --- a/src/core/app.py +++ b/src/core/app.py @@ -2,6 +2,7 @@ from fastapi import FastAPI from app.views import router from core.arq_pool import get_arq_pool +import core.sentry # noqa: F401 def start_app() -> FastAPI: diff --git a/src/core/config.py b/src/core/config.py index cd92f6e..50d6615 100644 --- a/src/core/config.py +++ b/src/core/config.py @@ -17,5 +17,7 @@ class EnvConfig(BaseSettings): MEILI_HOST: str MEILI_MASTER_KEY: str + SENTRY_SDN: str + env_config = EnvConfig() diff --git a/src/core/sentry.py b/src/core/sentry.py new file mode 100644 index 0000000..d83860d --- /dev/null +++ b/src/core/sentry.py @@ -0,0 +1,8 @@ +import sentry_sdk + +from core.config import env_config + + +sentry_sdk.init( + env_config.SENTRY_SDN, +) diff --git a/src/core/setup_arq.py b/src/core/setup_arq.py index 74d2e59..37e06ce 100644 --- a/src/core/setup_arq.py +++ b/src/core/setup_arq.py @@ -8,6 +8,7 @@ from app.services import ( update_genres, ) from core.arq_pool import get_redis_settings, get_arq_pool +import core.sentry # noqa: F401 async def startup(ctx):