Skip to content
Snippets Groups Projects
Commit 12b43fdf authored by Bjarke Madsen's avatar Bjarke Madsen
Browse files

Add sentry SDK to flask app and celery worker

parent 68aea16f
No related branches found
No related tags found
1 merge request!9Add sentry SDK to flask app and celery worker
"""
default app creation
"""
import os
import pkg_resources
import sentry_sdk
from sentry_sdk.integrations.flask import FlaskIntegration
sentry_dsn = os.getenv('SENTRY_DSN')
if sentry_dsn:
sentry_sdk.init(
dsn=sentry_dsn,
integrations=[FlaskIntegration()],
release=pkg_resources.get_distribution('inventory-provider').version)
# sentry should load before any other inventory-provider specific imports
import inventory_provider
from inventory_provider import environment
......
from celery import Celery
import os
import pkg_resources
import sentry_sdk
from sentry_sdk.integrations.celery import CeleryIntegration
from celery import Celery, signals
app = Celery("app")
app.config_from_object("inventory_provider.tasks.config")
@signals.celeryd_init.connect
def init_sentry(**_kwargs):
sentry_dsn = os.getenv('SENTRY_DSN')
dist = pkg_resources.get_distribution('inventory-provider')
if sentry_dsn:
sentry_sdk.init(
dsn=sentry_dsn,
integrations=[CeleryIntegration(propagate_traces=True)],
release=dist.version)
......@@ -21,3 +21,6 @@ pytest-mock
responses
sphinx
sphinx-rtd-theme
# glitchtip/sentry integration
sentry-sdk[flask,celery]
\ No newline at end of file
......@@ -26,7 +26,8 @@ setup(
'lxml',
'requests',
'netifaces',
'tree-format'
'tree-format',
'sentry-sdk[flask,celery]'
],
entry_points={
'console_scripts': [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment