From 27ea2852ea19ebc2bf6b433f2a3df6a813e88eaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Oberm=C3=BCller?= Date: Thu, 14 Mar 2024 14:17:38 +0100 Subject: [PATCH] feat(sentry): enable sampling via http header (#20916) --- posthog/settings/sentry.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/posthog/settings/sentry.py b/posthog/settings/sentry.py index 545d4ed94db2e..225e6dc61f51a 100644 --- a/posthog/settings/sentry.py +++ b/posthog/settings/sentry.py @@ -73,9 +73,13 @@ def traces_sampler(sampling_context: dict) -> float: if op == "http.server": path = sampling_context.get("wsgi_environ", {}).get("PATH_INFO") + force_sample = bool(sampling_context.get("wsgi_environ", {}).get("HTTP_FORCE_SAMPLE")) + # HTTP header to force sampling set + if force_sample: + return 1.0 # 100% # Ingestion endpoints (high volume) - if path.startswith("/batch"): + elif path.startswith("/batch"): return 0.00000001 # 0.000001% # Ingestion endpoints (high volume) elif path.startswith(("/capture", "/track", "/s", "/e")):