Commit 739ec3fd authored by Pierre Dittgen's avatar Pierre Dittgen

Integrate sentry

parent f2fd8005
......@@ -6,10 +6,11 @@
#
attrs==19.3.0 # via jsonschema
backports-datetime-fromisoformat==1.0.0 # via validata_ui (setup.py)
blinker==1.4 # via sentry-sdk
boto3==1.12.35 # via tabulator
botocore==1.15.35 # via boto3, s3transfer
cachecontrol==0.12.6 # via validata_ui (setup.py)
certifi==2019.11.28 # via requests
certifi==2019.11.28 # via requests, sentry-sdk
chardet==3.0.4 # via datapackage, requests, tabulator
click-default-group==1.2.2 # via goodtables
click==7.1.1 # via click-default-group, datapackage, flask, goodtables, opendataschema, tableschema, tabulator
......@@ -19,7 +20,7 @@ deprecated==1.2.7 # via pygithub
docutils==0.15.2 # via botocore, statistics
et-xmlfile==1.0.1 # via openpyxl
ezodf==0.3.2 # via validata-core, validata_ui (setup.py)
flask==1.1.1 # via validata_ui (setup.py)
flask==1.1.1 # via sentry-sdk, validata_ui (setup.py)
goodtables==2.4.12 # via validata-core
idna==2.9 # via requests
ijson==3.0 # via tabulator
......@@ -52,6 +53,7 @@ pytz==2019.3 # via pandas
requests==2.23.0 # via cachecontrol, datapackage, goodtables, opendataschema, pygithub, python-gitlab, tableschema, tabulator, validata-core, validata_ui (setup.py)
rfc3986==1.3.2 # via tableschema
s3transfer==0.3.3 # via boto3
sentry-sdk[flask]==0.14.3 # via validata_ui (setup.py)
simpleeval==0.9.10 # via goodtables
six==1.14.0 # via datapackage, goodtables, isodate, jsonlines, jsonschema, linear-tsv, pyrsistent, python-dateutil, tableschema, tabulator
sqlalchemy==1.3.15 # via tabulator
......@@ -62,7 +64,7 @@ tabulator==1.38.1 # via datapackage, goodtables, tableschema, validata-c
toml==0.10.0 # via validata_ui (setup.py)
toolz==0.10.0 # via validata-core
unicodecsv==0.14.1 # via datapackage, tableschema, tabulator
urllib3==1.25.8 # via botocore, requests
urllib3==1.25.8 # via botocore, requests, sentry-sdk
validata-core==0.5.6 # via validata_ui (setup.py)
werkzeug==1.0.1 # via flask
wrapt==1.12.1 # via deprecated
......
......@@ -65,6 +65,7 @@ setup(
'lxml',
'python-dotenv',
'requests',
'sentry-sdk[flask]==0.14.3',
'toml',
'tabulator',
......
......@@ -63,9 +63,21 @@ if config.HOMEPAGE_CONFIG:
schema_catalog_registry.add_ref(name, catalog_ref)
log.info("...done")
def configure_sentry(app):
"""Configure sentry.io service for application error monitoring."""
sentry_dsn = app.config.get("SENTRY_DSN")
if sentry_dsn:
import sentry_sdk
from sentry_sdk.integrations.flask import FlaskIntegration
sentry_sdk.init(dsn=sentry_dsn, integrations=[FlaskIntegration()])
# Flask things
app = flask.Flask(__name__)
app.secret_key = config.SECRET_KEY
configure_sentry(app)
# Jinja2 url_quote_plus custom filter
# https://stackoverflow.com/questions/12288454/how-to-import-custom-jinja2-filters-from-another-file-and-using-flask
......
......@@ -50,3 +50,5 @@ if MATOMO_BASE_URL:
MATOMO_SITE_ID = os.getenv("MATOMO_SITE_ID") or None
if MATOMO_SITE_ID:
MATOMO_SITE_ID = int(MATOMO_SITE_ID)
SENTRY_DSN = os.environ.get("SENTRY_DSN")
{% macro init_sentry(sentry_dsn) %}
<script
src="https://browser.sentry-cdn.com/5.13.0/bundle.min.js"
integrity="sha384-ePH2Cp6F+/PJbfhDWeQuXujAbpil3zowccx6grtsxOals4qYqJzCjeIa7W2UqunJ"
crossorigin="anonymous"></script>
<script>
Sentry.init({ dsn: "{{ sentry_dsn }}" });
</script>
{% endmacro %}
\ No newline at end of file
{% from "_sentry.html" import init_sentry %}
<!DOCTYPE html>
<html lang="fr">
......@@ -101,6 +102,10 @@
</script>
{% endif %}
{% if config.SENTRY_DSN %}
{{ init_sentry(config.SENTRY_DSN) }}
{% endif %}
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment