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

BITMAKER-4038: Add optional Sentry monitoring to the estela API #236

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions estela-api/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

import environ
from estela_queue_adapter import get_queue_env_vars
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent.parent
Expand Down Expand Up @@ -66,6 +68,8 @@
EMAIL_PORT=(int, "dummy"),
VERIFICATION_EMAIL=(str, "dummy"),
PROXY_PROVIDERS_TO_TRACK=(str, ""),
ENABLE_SENTRY=(bool, False),
SENTRY_DSN=(str, ""),
)
environ.Env.read_env(env_file=".env")

Expand Down Expand Up @@ -311,3 +315,10 @@
for name in env("PROXY_PROVIDERS_TO_TRACK").split(",")
]
)

if env("ENABLE_SENTRY"):
sentry_sdk.init(
dsn="your_public_dsn",
integrations=[DjangoIntegration()],
send_default_pii=True,
)
4 changes: 4 additions & 0 deletions estela-api/config/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@
COUNTDOWN_RECORD_COVERAGE_AFTER_JOB_EVENT = 30

SPIDERDATA_DB_PRODUCTION = False

if env("ENABLE_SENTRY"):
with sentry_sdk.configure_scope() as scope:
scope.set_tag("environment", "local")
5 changes: 5 additions & 0 deletions estela-api/config/settings/prod.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from config.settings.base import * # noqa: F401,F403,F405


DEBUG = False

RUN_JOBS_PER_LOT = 1000
Expand All @@ -20,3 +21,7 @@
DEFAULT_FILE_STORAGE = "config.storage_backends.MediaStorage"
STATIC_URL = "https://{}/{}/".format(AWS_S3_CUSTOM_DOMAIN, STATICFILES_LOCATION)
MEDIA_URL = "https://{}/{}/".format(AWS_S3_CUSTOM_DOMAIN, MEDIAFILES_LOCATION)

if env("ENABLE_SENTRY"):
with sentry_sdk.configure_scope() as scope:
scope.set_tag("environment", "production")
3 changes: 3 additions & 0 deletions estela-api/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from django.http import HttpResponse
from django.views import View

def trigger_error(request):
division_by_zero = 1 / 0

class HealthCheckView(View):
def get(self, request):
Expand All @@ -35,5 +37,6 @@ def get(self, request):
path("admin/", admin.site.urls),
path("api/", include("api.urls")),
path("", HealthCheckView.as_view()),
path("sentry-debug/", trigger_error),
]
urlpatterns = urlpatterns + django_external_apps_url
1 change: 1 addition & 0 deletions estela-api/requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ pymongo[srv]
redis
gunicorn
git+https://github.com/bitmakerla/estela-queue-adapter.git
sentry-sdk
4 changes: 4 additions & 0 deletions estela-api/requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ certifi==2020.12.5
# kubernetes
# minio
# requests
# sentry-sdk
chardet==4.0.0
# via requests
click==7.1.2
Expand Down Expand Up @@ -207,6 +208,8 @@ s3transfer==0.3.6
# via
# awscli
# boto3
sentry-sdk==1.9.0
# via -r base.in
six==1.15.0
# via
# click-repl
Expand All @@ -229,6 +232,7 @@ urllib3==1.25.11
# kubernetes
# minio
# requests
# sentry-sdk
vine==5.0.0
# via
# amqp
Expand Down
8 changes: 7 additions & 1 deletion estela-api/requirements/deploy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ certifi==2020.12.5
# kubernetes
# minio
# requests
# sentry-sdk
chardet==4.0.0
# via
# -r base.txt
Expand Down Expand Up @@ -241,7 +242,9 @@ pyasn1-modules==0.2.8
# -r base.txt
# google-auth
pymongo[srv]==3.12.0
# via -r base.txt
# via
# -r base.txt
# pymongo
pyparsing==2.4.7
# via
# -r base.txt
Expand Down Expand Up @@ -305,6 +308,8 @@ s3transfer==0.3.6
# -r base.txt
# awscli
# boto3
sentry-sdk==1.9.0
# via -r base.txt
six==1.15.0
# via
# -r base.txt
Expand Down Expand Up @@ -334,6 +339,7 @@ urllib3==1.25.11
# kubernetes
# minio
# requests
# sentry-sdk
vine==5.0.0
# via
# -r base.txt
Expand Down
8 changes: 7 additions & 1 deletion estela-api/requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ certifi==2020.12.5
# kubernetes
# minio
# requests
# sentry-sdk
chardet==4.0.0
# via
# -r test.txt
Expand Down Expand Up @@ -262,7 +263,9 @@ pyasn1-modules==0.2.8
# -r test.txt
# google-auth
pymongo[srv]==3.12.0
# via -r test.txt
# via
# -r test.txt
# pymongo
pyparsing==2.4.7
# via
# -r test.txt
Expand Down Expand Up @@ -331,6 +334,8 @@ s3transfer==0.3.6
# -r test.txt
# awscli
# boto3
sentry-sdk==1.9.0
# via -r test.txt
six==1.15.0
# via
# -r test.txt
Expand Down Expand Up @@ -362,6 +367,7 @@ urllib3==1.25.11
# kubernetes
# minio
# requests
# sentry-sdk
vine==5.0.0
# via
# -r test.txt
Expand Down
8 changes: 7 additions & 1 deletion estela-api/requirements/prod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ certifi==2020.12.5
# kubernetes
# minio
# requests
# sentry-sdk
chardet==4.0.0
# via
# -r base.txt
Expand Down Expand Up @@ -235,7 +236,9 @@ pyasn1-modules==0.2.8
# -r base.txt
# google-auth
pymongo[srv]==3.12.0
# via -r base.txt
# via
# -r base.txt
# pymongo
pyparsing==2.4.7
# via
# -r base.txt
Expand Down Expand Up @@ -298,6 +301,8 @@ s3transfer==0.3.6
# -r base.txt
# awscli
# boto3
sentry-sdk==1.9.0
# via -r base.txt
six==1.15.0
# via
# -r base.txt
Expand Down Expand Up @@ -327,6 +332,7 @@ urllib3==1.25.11
# kubernetes
# minio
# requests
# sentry-sdk
vine==5.0.0
# via
# -r base.txt
Expand Down
8 changes: 7 additions & 1 deletion estela-api/requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ certifi==2020.12.5
# kubernetes
# minio
# requests
# sentry-sdk
chardet==4.0.0
# via
# -r base.txt
Expand Down Expand Up @@ -249,7 +250,9 @@ pyasn1-modules==0.2.8
# -r base.txt
# google-auth
pymongo[srv]==3.12.0
# via -r base.txt
# via
# -r base.txt
# pymongo
pyparsing==2.4.7
# via
# -r base.txt
Expand Down Expand Up @@ -316,6 +319,8 @@ s3transfer==0.3.6
# -r base.txt
# awscli
# boto3
sentry-sdk==1.9.0
# via -r base.txt
six==1.15.0
# via
# -r base.txt
Expand Down Expand Up @@ -346,6 +351,7 @@ urllib3==1.25.11
# kubernetes
# minio
# requests
# sentry-sdk
vine==5.0.0
# via
# -r base.txt
Expand Down