From e7e327ba4df3f7b7d6a13bb1630dd9c7617aef15 Mon Sep 17 00:00:00 2001 From: Neil Kakkar Date: Mon, 2 Oct 2023 14:10:26 +0100 Subject: [PATCH] chore(decide): Update sentry profiling rate during spike (#17712) --- posthog/settings/sentry.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/posthog/settings/sentry.py b/posthog/settings/sentry.py index e1afc3c8ccde9..8aa2fe37f1620 100644 --- a/posthog/settings/sentry.py +++ b/posthog/settings/sentry.py @@ -10,6 +10,8 @@ from posthog.settings import get_from_env from posthog.settings.base_variables import TEST +from datetime import datetime, timezone + def traces_sampler(sampling_context: dict) -> float: # @@ -36,6 +38,12 @@ def traces_sampler(sampling_context: dict) -> float: return 0.0000001 # 0.00001% # Get more traces for /decide than other high volume endpoints elif path.startswith("/decide"): + # Get the current time in GMT + current_time_gmt = datetime.now(timezone.utc) + # Check if the time is between 5 and 6:59 am GMT, where we get spikes of latency + # so we can get more traces to debug + if 5 <= current_time_gmt.hour < 7: + return 0.001 # 0.1% return 0.00001 # 0.001% # Probes/monitoring endpoints elif path.startswith(("/_health", "/_readyz", "/_livez")):