8000 Exclude health checks from Sentry profiles sampling by krysal · Pull Request #5345 · WordPress/openverse · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Exclude health checks from Sentry profiles sampling #5345

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

Merged
merged 1 commit into from
Jan 24, 2025
Merged
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
26 changes: 23 additions & 3 deletions api/conf/settings/sentry.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,32 @@

SENTRY_DSN = config("SENTRY_DSN", default="")

SENTRY_TRACES_SAMPLE_RATE = config("SENTRY_TRACES_SAMPLE_RATE", default=0, cast=float)
SENTRY_PROFILES_SAMPLE_RATE = config(
SENTRY_TRACES_SAMPLE_RATE: float = config(
"SENTRY_TRACES_SAMPLE_RATE", default=0, cast=float
)
SENTRY_PROFILES_SAMPLE_RATE: float = config(
"SENTRY_PROFILES_SAMPLE_RATE", default=0, cast=float
)


def profiles_sampler(sampling_context) -> float:
"""
Control the performance profile sampling.
See https://docs.sentry.io/platforms/python/profiling/

Returns a float between 0.0 and 1.0.
"""
url_path = sampling_context.get("url.path", "")

if "healthcheck" in url_path:
return 0.0 # Exclude the health check URL from profiling

# All the other instances
return SENTRY_PROFILES_SAMPLE_RATE


INTEGRATIONS = [
# See https://docs.sentry.io/platforms/python/integrations/django/
DjangoIntegration(),
# This prevents two errors from being sent to Sentry (one with the correct
# information and the other with the logged JSON as the error name), since we
Expand All @@ -28,7 +48,7 @@
dsn=SENTRY_DSN,
integrations=INTEGRATIONS,
traces_sample_rate=SENTRY_TRACES_SAMPLE_RATE,
profiles_sample_rate=SENTRY_PROFILES_SAMPLE_RATE,
profiles_sampler=profiles_sampler,
send_default_pii=False,
environment=ENVIRONMENT,
)
Expand Down
Loading
0