From df29e05b6cc4eb927f74a419e546ffa4f6526d99 Mon Sep 17 00:00:00 2001 From: marcsello Date: Fri, 27 Nov 2020 18:16:37 +0100 Subject: [PATCH] Added sentry integrations --- caff_previewer_wrapper/app.py | 14 ++++++++++++++ caff_previewer_wrapper/config.py | 3 +++ requirements.txt | 3 ++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/caff_previewer_wrapper/app.py b/caff_previewer_wrapper/app.py index 98188a7..c4d9358 100644 --- a/caff_previewer_wrapper/app.py +++ b/caff_previewer_wrapper/app.py @@ -2,6 +2,8 @@ import tempfile import os import os.path import shutil +import sentry_sdk +from sentry_sdk.integrations.flask import FlaskIntegration from flask import Flask, current_app from config import Config @@ -9,6 +11,18 @@ from config import Config from utils import write_file_to_fd_while_calculating_md5, create_md5_sum_for_file from converter import convert_caff_to_tga, convert_tga_to_png +# Setup sentry +if Config.SENTRY_DSN: + sentry_sdk.init( + dsn=Config.SENTRY_DSN, + integrations=[FlaskIntegration()], + traces_sample_rate=1.0, + send_default_pii=True, + release=Config.RELEASE_ID, + environment=Config.RELEASEMODE, + _experiments={"auto_enabling_integrations": True} + ) + app = Flask(__name__) app.config.from_object(Config) diff --git a/caff_previewer_wrapper/config.py b/caff_previewer_wrapper/config.py index 5c60e49..1dabef8 100644 --- a/caff_previewer_wrapper/config.py +++ b/caff_previewer_wrapper/config.py @@ -7,3 +7,6 @@ class Config: CONVERSION_TIMEOUT = int(os.environ.get('IMAGEMAGICK_CONVERT_BINARY', 30)) RECIEVE_CHUNKSIZE = int(os.environ.get('RECIEVE_CHUNKSIZE', 2048)) MAX_RECIEVE_SIZE = int(os.environ.get('MAX_RECIEVE_SIZE', 536870912)) # 512 MB + SENTRY_DSN = os.environ.get('SENTRY_DSN') + RELEASE_ID = os.environ.get('RELEASE_ID', 'test') + RELEASEMODE = os.environ.get('RELEASEMODE', 'dev') diff --git a/requirements.txt b/requirements.txt index 7ed1285..e3be37d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ Flask~=1.1.2 -gunicorn~=20.0.4 \ No newline at end of file +gunicorn~=20.0.4 +sentry_sdk \ No newline at end of file