Add sentry

This commit is contained in:
2022-04-24 15:09:08 +03:00
parent 078ca87b4f
commit e4c0d9a9b9
7 changed files with 54 additions and 7 deletions

View File

@@ -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")

View File

@@ -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:

View File

@@ -17,5 +17,7 @@ class EnvConfig(BaseSettings):
MEILI_HOST: str
MEILI_MASTER_KEY: str
SENTRY_SDN: str
env_config = EnvConfig()

8
src/core/sentry.py Normal file
View File

@@ -0,0 +1,8 @@
import sentry_sdk
from core.config import env_config
sentry_sdk.init(
env_config.SENTRY_SDN,
)

View File

@@ -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):