Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add utilities to integrate with Sentry
- Loading branch information
1 parent
5c3fd67
commit ae0ee68
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
""" | ||
byceps.util.sentry | ||
~~~~~~~~~~~~~~~~~~ | ||
Sentry_ integration | ||
.. _Sentry: https://sentry.io/ | ||
:Copyright: 2006-2020 Jochen Kupperschmidt | ||
:License: Modified BSD, see LICENSE for details. | ||
""" | ||
|
||
from flask import Flask | ||
|
||
|
||
def configure_sentry_for_webapp(dsn: str, environment: str, app: Flask) -> None: | ||
"""Initialize and configure the Sentry SDK for the Flask-based web | ||
application (both in 'admin' and 'site' modes). | ||
""" | ||
import sentry_sdk | ||
from sentry_sdk.integrations.flask import FlaskIntegration | ||
|
||
sentry_sdk.init( | ||
dsn=dsn, environment=environment, integrations=[FlaskIntegration()], | ||
) | ||
|
||
sentry_sdk.set_tag('app_mode', app.config.get('APP_MODE')) | ||
sentry_sdk.set_tag('site_id', app.config.get('SITE_ID')) | ||
|
||
|
||
def configure_sentry_for_worker(dsn: str, environment: str) -> None: | ||
"""Initialize and configure the Sentry SDK for the RQ worker.""" | ||
import sentry_sdk | ||
from sentry_sdk.integrations.rq import RqIntegration | ||
|
||
sentry_sdk.init( | ||
dsn=dsn, environment=environment, integrations=[RqIntegration()], | ||
) | ||
|
||
sentry_sdk.set_tag('app_mode', 'worker') |