summaryrefslogtreecommitdiffstats
path: root/takahe
diff options
context:
space:
mode:
authorMichael Manfre2022-12-04 20:08:23 -0500
committerGitHub2022-12-04 18:08:23 -0700
commit3f8045f4128d14558636b1c8a9445c29e8e1583d (patch)
treee36e7b4a928f9b8497283934d60e512ec02a818b /takahe
parent258d992deb06a1ffd82ad33004223cf518ce3aa3 (diff)
downloadtakahe-3f8045f4128d14558636b1c8a9445c29e8e1583d.tar.gz
takahe-3f8045f4128d14558636b1c8a9445c29e8e1583d.tar.bz2
takahe-3f8045f4128d14558636b1c8a9445c29e8e1583d.zip
[WIP] Sentry improvements (#108)
Stator clears scope during the main loop to behave more like transactions. Transaction names are set. Sentry tags: * 'takahe.version' * 'takahe.app' values 'web' or 'stator' Added settings: * TAKAHE_SENTRY_SAMPLE_RATE * TAKAHE_SENTRY_TRACES_SAMPLE_RATE
Diffstat (limited to 'takahe')
-rw-r--r--takahe/settings.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/takahe/settings.py b/takahe/settings.py
index 856c22c..15f30ee 100644
--- a/takahe/settings.py
+++ b/takahe/settings.py
@@ -10,6 +10,8 @@ import sentry_sdk
from pydantic import AnyUrl, BaseSettings, EmailStr, Field, validator
from sentry_sdk.integrations.django import DjangoIntegration
+from takahe import __version__
+
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -77,6 +79,8 @@ class Settings(BaseSettings):
#: An optional Sentry DSN for error reporting.
SENTRY_DSN: Optional[str] = None
+ SENTRY_SAMPLE_RATE: float = 1.0
+ SENTRY_TRACES_SAMPLE_RATE: float = 1.0
#: Fallback domain for links.
MAIN_DOMAIN: str = "example.com"
@@ -150,6 +154,7 @@ INSTALLED_APPS = [
]
MIDDLEWARE = [
+ "core.middleware.SentryTaggingMiddleware",
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
@@ -269,10 +274,12 @@ if SETUP.SENTRY_DSN:
integrations=[
DjangoIntegration(),
],
- traces_sample_rate=1.0,
+ traces_sample_rate=SETUP.SENTRY_TRACES_SAMPLE_RATE,
+ sample_rate=SETUP.SENTRY_SAMPLE_RATE,
send_default_pii=True,
environment=SETUP.ENVIRONMENT,
)
+ sentry_sdk.set_tag("takahe.version", __version__)
SERVER_EMAIL = SETUP.EMAIL_FROM
if SETUP.EMAIL_SERVER: