summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDashie <dashie@sigpipe.me>2019-06-20 11:07:48 +0200
committerDashie <dashie@sigpipe.me>2019-06-20 11:07:48 +0200
commit6f661d41bb676536a79c5685d5cf0760527eb30f (patch)
treed2b8fd36d98c33b6e0f88b30263e9db9034de62d
parentbe3e11dbbf2e74750f7523726eb9d746a0d4fd1e (diff)
Improve sentry support with new SDK
-rw-r--r--README.md4
-rw-r--r--app.py35
-rw-r--r--config.py.sample1
-rw-r--r--tests/config_test.py1
4 files changed, 23 insertions, 18 deletions
diff --git a/README.md b/README.md
index ae410647..a69fdd44 100644
--- a/README.md
+++ b/README.md
@@ -54,6 +54,10 @@ Or if you have disabled registration, use the ``` flask createuser ``` command t
pip install waitress
+ # If you want SENTRY support (also add related things in config)
+ pip install sentry-sdk[flask]
+
+
Copy systemd services files ```docs/reel2bits-*.service``` to ```/etc/systemd/system/``` and adapt them to your setup.
systemctl enable reel2bits-web reel2bits-worker
diff --git a/app.py b/app.py
index 3c8446f4..94b1c2af 100644
--- a/app.py
+++ b/app.py
@@ -36,17 +36,24 @@ __VERSION__ = VERSION
AVAILABLE_LOCALES = ["fr", "fr_FR", "en", "en_US", "pl"]
try:
- from raven.contrib.flask import Sentry
- import raven
+ import sentry_sdk
+ from sentry_sdk.integrations.flask import FlaskIntegration as SentryFlaskIntegration
+ from sentry_sdk.integrations.celery import CeleryIntegration as SentryCeleryIntegration
- print(" * Sentry support loaded")
+ print(" * Sentry Flask/Celery support have been loaded")
HAS_SENTRY = True
except ImportError:
- print(" * No Sentry support")
+ print(" * No Sentry Flask/Celery support available")
HAS_SENTRY = False
mail = Mail()
+GIT_VERSION = ""
+gitpath = os.path.join(os.getcwd(), ".git")
+if os.path.isdir(gitpath):
+ GIT_VERSION = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])
+ if GIT_VERSION:
+ GIT_VERSION = GIT_VERSION.strip().decode("UTF-8")
def make_celery(remoulade):
celery = Celery(remoulade.import_name, broker=remoulade.config["CELERY_BROKER_URL"])
@@ -78,9 +85,12 @@ def create_app(config_filename="config.py", app_name=None, register_blueprints=T
app.jinja_env.globals.update(duration_song_human=duration_song_human)
if HAS_SENTRY:
- app.config["SENTRY_RELEASE"] = raven.fetch_git_sha(os.path.dirname(__file__))
- sentry = Sentry(app, dsn=app.config["SENTRY_DSN"]) # noqa: F841
- print(" * Sentry support activated")
+ sentry_sdk.init(
+ app.config["SENTRY_DSN"],
+ integrations=[SentryFlaskIntegration(), SentryCeleryIntegration()],
+ release=f"{VERSION} ({GIT_VERSION})"
+ )
+ print(" * Sentry Flask/Celery support activated")
print(" * Sentry DSN: %s" % app.config["SENTRY_DSN"])
if app.config["DEBUG"] is True:
@@ -136,13 +146,6 @@ def create_app(config_filename="config.py", app_name=None, register_blueprints=T
db.session.add(actor)
db.session.commit()
- git_version = ""
- gitpath = os.path.join(os.getcwd(), ".git")
- if os.path.isdir(gitpath):
- git_version = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])
- if git_version:
- git_version = git_version.strip().decode("UTF-8")
-
@babel.localeselector
def get_locale():
# if a user is logged in, use the locale from the user settings
@@ -169,8 +172,8 @@ def create_app(config_filename="config.py", app_name=None, register_blueprints=T
cfg = {
"REEL2BITS_VERSION_VER": VERSION,
- "REEL2BITS_VERSION_GIT": git_version,
- "REEL2BITS_VERSION": "{0} ({1})".format(VERSION, git_version),
+ "REEL2BITS_VERSION_GIT": GIT_VERSION,
+ "REEL2BITS_VERSION": "{0} ({1})".format(VERSION, GIT_VERSION),
"app_name": _config.app_name,
"app_description": _config.app_description,
}
diff --git a/config.py.sample b/config.py.sample
index 6d159595..ac9666b4 100644
--- a/config.py.sample
+++ b/config.py.sample
@@ -10,7 +10,6 @@ TEMP_DOWNLOAD_FOLDER = "/home/reel2bits/tmp"
AUDIOWAVEFORM_BIN = "/usr/local/bin/audiowaveform"
# If using sentry, set a DSN
-SENTRY_USER_ATTRS = ['name', 'email']
SENTRY_DSN = ""
# Redis configuration for broker, used for async background tasks
diff --git a/tests/config_test.py b/tests/config_test.py
index c01d0d32..504ab2ef 100644
--- a/tests/config_test.py
+++ b/tests/config_test.py
@@ -47,7 +47,6 @@ TEMP_DOWNLOAD_FOLDER = "/home/dashie/dev/reel2bits/tmp"
AUDIOWAVEFORM_BIN = "/usr/local/bin/audiowaveform"
# Sentry
-SENTRY_USER_ATTRS = ["name", "email"]
SENTRY_DSN = ""
# Bcrypt algorithm hashing rounds (reduced for testing purposes only!)