Merge pull request #28304 from gavindsouza/enable-sentry-profiling

feat: Enable Sentry Sampling
This commit is contained in:
gavin 2024-10-29 10:26:00 +01:00 committed by GitHub
commit 85235d1252
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 1 deletions

View file

@ -476,6 +476,9 @@ if sentry_dsn := os.getenv("FRAPPE_SENTRY_DSN"):
kwargs["traces_sample_rate"] = float(tracing_sample_rate)
application = SentryWsgiMiddleware(application)
if profiling_sample_rate := os.getenv("SENTRY_PROFILING_SAMPLE_RATE"):
kwargs["profiles_sample_rate"] = float(profiling_sample_rate)
sentry_sdk.init(
dsn=sentry_dsn,
before_send=before_send,

View file

@ -445,7 +445,9 @@ before_job = [
]
if os.getenv("FRAPPE_SENTRY_DSN") and (
os.getenv("ENABLE_SENTRY_DB_MONITORING") or os.getenv("SENTRY_TRACING_SAMPLE_RATE")
os.getenv("ENABLE_SENTRY_DB_MONITORING")
or os.getenv("SENTRY_TRACING_SAMPLE_RATE")
or os.getenv("SENTRY_PROFILING_SAMPLE_RATE")
):
before_request.append("frappe.utils.sentry.set_sentry_context")
before_job.append("frappe.utils.sentry.set_sentry_context")

View file

@ -695,6 +695,9 @@ def _start_sentry():
if tracing_sample_rate := os.getenv("SENTRY_TRACING_SAMPLE_RATE"):
kwargs["traces_sample_rate"] = float(tracing_sample_rate)
if profiling_sample_rate := os.getenv("SENTRY_PROFILING_SAMPLE_RATE"):
kwargs["profiles_sample_rate"] = float(profiling_sample_rate)
sentry_sdk.init(
dsn=sentry_dsn,
before_send=before_send,

View file

@ -112,6 +112,7 @@ def capture_exception(message: str | None = None) -> None:
if (
os.getenv("ENABLE_SENTRY_DB_MONITORING") is None
or os.getenv("SENTRY_TRACING_SAMPLE_RATE") is None
or os.getenv("SENTRY_PROFILING_SAMPLE_RATE") is None
):
set_scope(scope)
if frappe.request: