feat: add sentry sdk

This commit is contained in:
jo 2023-02-26 23:24:29 +01:00 committed by Kyle Robbertze
parent a60d83311b
commit b7214b5d46
14 changed files with 86 additions and 12 deletions

View file

@ -4,7 +4,7 @@ include ../tools/python.mk
PIP_INSTALL := \
--editable ../shared \
--editable .[dev]
--editable .[dev,sentry]
PYLINT_ARG := libretime_api
MYPY_ARG := libretime_api
BANDIT_ARG := --exclude '*/tests/*' libretime_api || true

View file

@ -1,6 +1,8 @@
from os import getenv
from os import environ, getenv
from typing import Optional
from .. import PACKAGE, VERSION
API_VERSION = "2.0.0"
# SECURITY WARNING: don't run with debug turned on in production!
@ -178,3 +180,18 @@ SPECTACULAR_SETTINGS = {
"VERSION": API_VERSION,
"ENUM_NAME_OVERRIDES": SPECTACULAR_ENUM_NAME_OVERRIDES,
}
# Sentry
# https://docs.sentry.io/platforms/python/guides/django/
if "SENTRY_DSN" in environ:
# pylint: disable=import-outside-toplevel
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
sentry_sdk.init(
traces_sample_rate=1.0,
release=f"{PACKAGE}@{VERSION}",
integrations=[
DjangoIntegration(),
],
)

View file

@ -44,5 +44,8 @@ setup(
"pytest-django>=4.5.2,<4.6",
"requests-mock>=1.10.0,<1.11",
],
"sentry": [
"sentry-sdk[django]>=1.15.0,<1.16",
],
},
)