diff options
author | Martin Czygan <martin.czygan@gmail.com> | 2021-12-14 00:44:09 +0100 |
---|---|---|
committer | Martin Czygan <martin.czygan@gmail.com> | 2021-12-14 00:56:59 +0100 |
commit | a49df4d8f6c08ecd7a5b97a8a538b4a6f419e015 (patch) | |
tree | fa2e6d7f3ab6e7e7912e838c5da2d0659c974d5b /python/fatcat_web | |
parent | 07b9dfe28b4732f0ca52dc4fd571ea238d953279 (diff) | |
download | fatcat-a49df4d8f6c08ecd7a5b97a8a538b4a6f419e015.tar.gz fatcat-a49df4d8f6c08ecd7a5b97a8a538b4a6f419e015.zip |
move from raven to sentry_sdk
related docs:
* https://docs.sentry.io/platforms/python/guides/flask/migration/
* https://docs.sentry.io/platforms/python/guides/asgi/configuration/integrations/flask/
> `fetch_git_sha` is gone, see: https://forum.sentry.io/t/fetch-git-sha-equivalent-in-the-unified-python-sdk/5521
Diffstat (limited to 'python/fatcat_web')
-rw-r--r-- | python/fatcat_web/__init__.py | 5 | ||||
-rw-r--r-- | python/fatcat_web/web_config.py | 12 |
2 files changed, 12 insertions, 5 deletions
diff --git a/python/fatcat_web/__init__.py b/python/fatcat_web/__init__.py index 5cb56d0b..a89c5bbe 100644 --- a/python/fatcat_web/__init__.py +++ b/python/fatcat_web/__init__.py @@ -13,7 +13,8 @@ from flask_mwoauth import MWOAuth from flask_uuid import FlaskUUID from flask_wtf.csrf import CSRFProtect from loginpass import GitHub, Gitlab, ORCiD, create_flask_blueprint -from raven.contrib.flask import Sentry +import sentry_sdk +from sentry_sdk.integrations.flask import FlaskIntegration from fatcat_web.types import AnyResponse from fatcat_web.web_config import Config @@ -44,7 +45,7 @@ login_manager.login_view = "/auth/login" oauth = OAuth(app) # Grabs sentry config from SENTRY_DSN environment variable -sentry = Sentry(app) +sentry_sdk.init(integrations=[FlaskIntegration()]) conf = fatcat_openapi_client.Configuration() conf.host = Config.FATCAT_API_HOST diff --git a/python/fatcat_web/web_config.py b/python/fatcat_web/web_config.py index 82525487..005986bd 100644 --- a/python/fatcat_web/web_config.py +++ b/python/fatcat_web/web_config.py @@ -12,8 +12,6 @@ import os import subprocess from typing import Union -import raven - basedir = os.path.abspath(os.path.dirname(__file__)) @@ -44,6 +42,14 @@ def test_bool_str() -> None: assert bool_str("True") is True assert bool_str("FALSE") is False +def fetch_git_sha(): + """ + Get short commit id, runnable anywhere within a git repository. + """ + return subprocess.check_output(['git', + 'rev-parse', + '--short', + 'HEAD']).decode('ascii').strip() class Config(object): GIT_REVISION = ( @@ -137,7 +143,7 @@ class Config(object): PERMANENT_SESSION_LIFETIME = 2678400 # 31 days, in seconds try: - GIT_RELEASE = raven.fetch_git_sha("..") + GIT_RELEASE = fetch_git_sha() except Exception as e: print("WARNING: couldn't set sentry git release automatically: " + str(e)) GIT_RELEASE = None |