Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#198 chore: add settings to api and refactor sentry settings #199

Merged
merged 1 commit into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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