Merge pull request #308 from eReuse/feature/3535-sentry
add sentry to app
This commit is contained in:
commit
9e7e10208b
|
@ -3,7 +3,11 @@ Example app with minimal configuration.
|
||||||
|
|
||||||
Use this as a starting point.
|
Use this as a starting point.
|
||||||
"""
|
"""
|
||||||
|
import sentry_sdk
|
||||||
|
from decouple import config
|
||||||
from flask_wtf.csrf import CSRFProtect
|
from flask_wtf.csrf import CSRFProtect
|
||||||
|
from sentry_sdk.integrations.flask import FlaskIntegration
|
||||||
|
from werkzeug.contrib.profiler import ProfilerMiddleware
|
||||||
|
|
||||||
from ereuse_devicehub.api.views import api
|
from ereuse_devicehub.api.views import api
|
||||||
from ereuse_devicehub.config import DevicehubConfig
|
from ereuse_devicehub.config import DevicehubConfig
|
||||||
|
@ -13,6 +17,20 @@ from ereuse_devicehub.labels.views import labels
|
||||||
from ereuse_devicehub.views import core
|
from ereuse_devicehub.views import core
|
||||||
from ereuse_devicehub.workbench.views import workbench
|
from ereuse_devicehub.workbench.views import workbench
|
||||||
|
|
||||||
|
SENTRY_DSN = config('SENTRY_DSN', None)
|
||||||
|
if SENTRY_DSN:
|
||||||
|
sentry_sdk.init(
|
||||||
|
dsn=SENTRY_DSN,
|
||||||
|
integrations=[
|
||||||
|
FlaskIntegration(),
|
||||||
|
],
|
||||||
|
# Set traces_sample_rate to 1.0 to capture 100%
|
||||||
|
# of transactions for performance monitoring.
|
||||||
|
# We recommend adjusting this value in production.
|
||||||
|
traces_sample_rate=1.0,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
app = Devicehub(inventory=DevicehubConfig.DB_SCHEMA)
|
app = Devicehub(inventory=DevicehubConfig.DB_SCHEMA)
|
||||||
app.register_blueprint(core)
|
app.register_blueprint(core)
|
||||||
app.register_blueprint(devices)
|
app.register_blueprint(devices)
|
||||||
|
@ -26,3 +44,7 @@ app.register_blueprint(workbench)
|
||||||
csrf = CSRFProtect(app)
|
csrf = CSRFProtect(app)
|
||||||
# csrf.protect(core)
|
# csrf.protect(core)
|
||||||
# csrf.protect(devices)
|
# csrf.protect(devices)
|
||||||
|
app.config["SQLALCHEMY_RECORD_QUERIES"] = True
|
||||||
|
app.config['PROFILE'] = True
|
||||||
|
app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30])
|
||||||
|
app.run(debug=True)
|
||||||
|
|
|
@ -45,3 +45,4 @@ python-dotenv==0.14.0
|
||||||
pyjwt==2.4.0
|
pyjwt==2.4.0
|
||||||
pint==0.9
|
pint==0.9
|
||||||
py-dmidecode==0.1.0
|
py-dmidecode==0.1.0
|
||||||
|
sentry_sdk==1.6.0
|
||||||
|
|
Reference in New Issue