Total Complexity | 2 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | """ |
||
2 | byceps.util.sentry |
||
3 | ~~~~~~~~~~~~~~~~~~ |
||
4 | |||
5 | Sentry_ integration |
||
6 | |||
7 | .. _Sentry: https://sentry.io/ |
||
8 | |||
9 | :Copyright: 2006-2020 Jochen Kupperschmidt |
||
10 | :License: Modified BSD, see LICENSE for details. |
||
11 | """ |
||
12 | |||
13 | from flask import Flask |
||
14 | |||
15 | |||
16 | def configure_sentry_for_webapp(dsn: str, environment: str, app: Flask) -> None: |
||
17 | """Initialize and configure the Sentry SDK for the Flask-based web |
||
18 | application (both in 'admin' and 'site' modes). |
||
19 | """ |
||
20 | import sentry_sdk |
||
21 | from sentry_sdk.integrations.flask import FlaskIntegration |
||
22 | |||
23 | sentry_sdk.init( |
||
24 | dsn=dsn, environment=environment, integrations=[FlaskIntegration()], |
||
25 | ) |
||
26 | |||
27 | sentry_sdk.set_tag('app_mode', app.config.get('APP_MODE')) |
||
28 | sentry_sdk.set_tag('site_id', app.config.get('SITE_ID')) |
||
29 | |||
30 | |||
31 | def configure_sentry_for_worker(dsn: str, environment: str) -> None: |
||
32 | """Initialize and configure the Sentry SDK for the RQ worker.""" |
||
33 | import sentry_sdk |
||
34 | from sentry_sdk.integrations.rq import RqIntegration |
||
35 | |||
36 | sentry_sdk.init( |
||
37 | dsn=dsn, environment=environment, integrations=[RqIntegration()], |
||
38 | ) |
||
39 | |||
40 | sentry_sdk.set_tag('app_mode', 'worker') |
||
41 |