Skip to content

Commit 49417c8

Browse files
Kwaizeranfimovdm
authored andcommitted
Add Sentry support (AlmaLinux#113)
1 parent 79ea0e4 commit 49417c8

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

alts/scheduler/app.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import aiohttp
88
import logging
9+
import sentry_sdk
910
import signal
1011
import urllib.parse
1112
from threading import Event
@@ -40,6 +41,15 @@
4041
graceful_terminate_event = Event()
4142
http_bearer_scheme = HTTPBearer()
4243

44+
if CONFIG.sentry_dsn:
45+
sentry_sdk.init(
46+
dsn=CONFIG.sentry_dsn,
47+
traces_sample_rate=CONFIG.sentry_traces_sample_rate,
48+
environment=CONFIG.sentry_environment,
49+
ignore_errors=[
50+
ConnectionResetError
51+
],
52+
)
4353

4454
def get_celery_task_result(task_id: str, timeout: int = 1) -> tuple:
4555
"""

alts/shared/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,3 +384,6 @@ class SchedulerConfig(CeleryConfig):
384384
working_directory: str = '/srv/alts/scheduler'
385385
jwt_secret: str
386386
hashing_algorithm: str = 'HS256'
387+
sentry_dsn: str = None
388+
sentry_traces_sample_rate: float = 0.2
389+
sentry_environment: str = 'dev'

alts/worker/app.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import itertools
22
import logging
3+
import sentry_sdk
34

45
from celery import Celery
56
from kombu import Exchange, Queue
@@ -32,6 +33,16 @@
3233
celery_app.conf.task_default_exchange = 'default'
3334
celery_app.conf.task_default_routing_key = 'default'
3435

36+
if CONFIG.sentry_dsn:
37+
sentry_sdk.init(
38+
dsn=CONFIG.sentry_dsn,
39+
traces_sample_rate=CONFIG.sentry_traces_sample_rate,
40+
environment=CONFIG.sentry_environment,
41+
ignore_errors=[
42+
ConnectionResetError
43+
],
44+
)
45+
3546
if CONFIG.use_ssl:
3647
if not getattr(CONFIG, 'ssl_config'):
3748
raise ValueError('Empty SSL configuration section')

requirements/base.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ pulpcore-client==3.61.0
1212
pydantic==2.9.2
1313
pyone==6.10.0
1414
requests==2.32.3
15+
sentry-sdk==2.22.0
1516
syncer==2.0.3
1617
tap.py==3.1

0 commit comments

Comments
 (0)