Skip to content

Commit

Permalink
#198 chore: add settings to api and refactor sentry settings
Browse files Browse the repository at this point in the history
  • Loading branch information
zsinnema committed May 19, 2021
1 parent 8fd2ae8 commit 37f54d2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 17 deletions.
10 changes: 10 additions & 0 deletions scidash/general/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,13 @@ def get(self, request):
}, 200
)

class SettingsView(APIView):
def get(self, request):
return Response(
{
'sentry': {
'dsn': s.SENTRY_DSN,
'env': s.SENTRY_ENV
}
}, 200
)
34 changes: 17 additions & 17 deletions scidash/main/sentry.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import os
import sentry_sdk

from django.conf import settings
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.celery import CeleryIntegration
from sentry_sdk.integrations.redis import RedisIntegration


sentry_environment = os.environ.get("ENVIRONMENT", "Production")


def init():
sentry_sdk.init(
dsn=os.environ.get('SENTRY_DSN', ""),
environment=sentry_environment,
integrations=[CeleryIntegration(),
DjangoIntegration(),
RedisIntegration()],
# sentry_sdk.init(
# dsn=settings.SENTRY_DSN,
# environment=settings.SENTRY_ENV,
# integrations=[CeleryIntegration(),
# DjangoIntegration(),
# RedisIntegration()],

# 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,
# # 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,

# If you wish to associate users to errors (assuming you are using
# django.contrib.auth) you may enable sending PII data.
send_default_pii=True
)
# # If you wish to associate users to errors (assuming you are using
# # django.contrib.auth) you may enable sending PII data.
# # send_default_pii=True
# )
pass
2 changes: 2 additions & 0 deletions scidash/main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import dotenv
from django.urls import reverse

SENTRY_ENV = os.environ.get("ENVIRONMENT", "Production")
SENTRY_DSN = os.environ.get('SENTRY_DSN', "")
from .sentry import init as sentry_init

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
Expand Down
5 changes: 5 additions & 0 deletions scidash/main/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@
general_views.InstructionsView.as_view(),
name='instructions-view'
),
url(
r'^api/settings/$',
general_views.SettingsView.as_view(),
name='instructions-view'
),
url(r'^api/parameters/$', models_views.ModelParametersView.as_view()),
url(
r'^api/compatibility/$',
Expand Down

0 comments on commit 37f54d2

Please sign in to comment.