File tree Expand file tree Collapse file tree 9 files changed +47
-16
lines changed
Expand file tree Collapse file tree 9 files changed +47
-16
lines changed Original file line number Diff line number Diff line change 11import importlib
22import logging
33
4- import sentry_sdk
54from fastapi import FastAPI
65from fastapi_sqla import setup as fastapi_sqla_setup
7- from pika .exceptions import StreamLostError
86from starlette .middleware .exceptions import ExceptionMiddleware
97
108from alws import routers
1614from alws .config import settings
1715from alws .middlewares import handlers
1816from alws .utils .limiter import limiter_shutdown , limiter_startup
17+ from alws .utils .sentry import sentry_init
1918
2019logging .basicConfig (level = settings .logging_level )
2120
2726AUTH_PREFIX = APP_PREFIX + '/auth'
2827AUTH_TAG = 'auth'
2928
30- if settings .sentry_dsn :
31- sentry_sdk .init (
32- dsn = settings .sentry_dsn ,
33- traces_sample_rate = settings .sentry_traces_sample_rate ,
34- environment = settings .sentry_environment ,
35- ignore_errors = [
36- ConnectionResetError ,
37- StreamLostError ,
38- ],
39- )
29+ sentry_init ()
4030
4131
4232app = FastAPI ()
Original file line number Diff line number Diff line change 3838 move_issues ,
3939 set_build_id_to_issues ,
4040)
41+ from alws .utils .sentry import sentry_init
42+
4143
4244__all__ = ['start_build' , 'build_done' ]
4345
4446logger = logging .getLogger (__name__ )
4547
48+ sentry_init ()
4649
4750def _sync_fetch_build (db : Session , build_id : int ) -> models .Build :
4851 query = select (models .Build ).where (models .Build .id == build_id )
Original file line number Diff line number Diff line change 1414)
1515from alws .dramatiq import event_loop
1616from alws .utils .fastapi_sqla_setup import setup_all
17+ from alws .utils .sentry import sentry_init
1718
1819__all__ = ["release_errata" ]
1920
2021
22+ sentry_init ()
23+
24+
2125async def _create_new_errata_record (errata ):
2226 await create_new_errata_record (errata )
2327
Original file line number Diff line number Diff line change 1717from alws .utils .fastapi_sqla_setup import setup_all
1818from alws .utils .log_utils import setup_logger
1919from alws .utils .pulp_client import PulpClient
20+ from alws .utils .sentry import sentry_init
2021
2122__all__ = ['perform_product_modification' ]
2223
2324logger = setup_logger (__name__ )
2425
2526
27+ sentry_init ()
28+
29+
2630async def get_existing_packages (
2731 pulp_client : PulpClient ,
2832 repository : models .Repository ,
Original file line number Diff line number Diff line change 1- from contextlib import asynccontextmanager
2-
31import dramatiq
42from fastapi_sqla import open_async_session
53
86from alws .dependencies import get_async_db_key
97from alws .dramatiq import event_loop
108from alws .utils .fastapi_sqla_setup import setup_all
9+ from alws .utils .sentry import sentry_init
1110
1211__all__ = ["execute_release_plan" ]
1312
1413
14+ sentry_init ()
15+
16+
1517async def _commit_release (release_id , user_id ):
1618 async with open_async_session (key = get_async_db_key ()) as db :
1719 await r_crud .commit_release (db , release_id , user_id )
Original file line number Diff line number Diff line change 11import typing
22
33import dramatiq
4-
54from alws .constants import DRAMATIQ_TASK_TIMEOUT
65from alws .crud import sign_task
76from alws .dramatiq import event_loop
87from alws .schemas import sign_schema
98from alws .utils .fastapi_sqla_setup import setup_all
9+ from alws .utils .sentry import sentry_init
1010
1111__all__ = ['complete_sign_task' ]
1212
1313
14+ sentry_init ()
15+
16+
1417async def _complete_sign_task (
1518 task_id : int , payload : typing .Dict [str , typing .Any ]
1619):
Original file line number Diff line number Diff line change 33
44import dramatiq
55from fastapi_sqla import open_async_session
6-
76from alws .constants import DRAMATIQ_TASK_TIMEOUT , TestTaskStatus
87from alws .crud import test as t_crud
98from alws .dependencies import get_async_db_key
109from alws .dramatiq import event_loop
1110from alws .schemas .test_schema import TestTaskResult
1211from alws .utils .fastapi_sqla_setup import setup_all
12+ from alws .utils .sentry import sentry_init
1313
1414__all__ = ['complete_test_task' ]
1515
1616
17+ sentry_init ()
18+
19+
1720async def _complete_test_task (task_id : int , task_result : TestTaskResult ):
1821 async with open_async_session (key = get_async_db_key ()) as db :
1922 try :
Original file line number Diff line number Diff line change 99from alws .dependencies import get_async_db_key
1010from alws .dramatiq import event_loop
1111from alws .utils .fastapi_sqla_setup import setup_all
12+ from alws .utils .sentry import sentry_init
1213
1314__all__ = ['perform_user_removal' ]
1415
1516
17+ sentry_init ()
18+
19+
1620async def _perform_user_removal (user_id : int ):
1721 async with open_async_session (key = get_async_db_key ()) as db :
1822 # Remove builds
Original file line number Diff line number Diff line change 1+ import sentry_sdk
2+ from pika .exceptions import StreamLostError
3+
4+ from alws .config import settings
5+
6+
7+ def sentry_init ():
8+ if not settings .sentry_dsn :
9+ return
10+ sentry_sdk .init (
11+ dsn = settings .sentry_dsn ,
12+ traces_sample_rate = settings .sentry_traces_sample_rate ,
13+ environment = settings .sentry_environment ,
14+ ignore_errors = [
15+ ConnectionResetError ,
16+ StreamLostError ,
17+ ],
18+ )
You can’t perform that action at this time.
0 commit comments