root: ignore healthcheck routes in sentry tracing
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
4c0e19cbea
commit
85784f796c
|
@ -56,7 +56,6 @@ def sentry_init(**sentry_init_kwargs):
|
|||
"""Configure sentry SDK"""
|
||||
sentry_env = CONFIG.y("error_reporting.environment", "customer")
|
||||
kwargs = {
|
||||
"traces_sample_rate": float(CONFIG.y("error_reporting.sample_rate", 0.5)),
|
||||
"environment": sentry_env,
|
||||
"send_default_pii": CONFIG.y_bool("error_reporting.send_pii", False),
|
||||
}
|
||||
|
@ -71,6 +70,7 @@ def sentry_init(**sentry_init_kwargs):
|
|||
ThreadingIntegration(propagate_hub=True),
|
||||
],
|
||||
before_send=before_send,
|
||||
traces_sampler=traces_sampler,
|
||||
release=f"authentik@{__version__}",
|
||||
**kwargs,
|
||||
)
|
||||
|
@ -83,6 +83,14 @@ def sentry_init(**sentry_init_kwargs):
|
|||
)
|
||||
|
||||
|
||||
def traces_sampler(sampling_context: dict) -> float:
|
||||
"""Custom sampler to ignore certain routes"""
|
||||
# Ignore all healthcheck routes
|
||||
if sampling_context.get("asgi_scope", {}).get("path", "").startswith("/-/health/"):
|
||||
return 0
|
||||
return float(CONFIG.y("error_reporting.sample_rate", 0.5))
|
||||
|
||||
|
||||
def before_send(event: dict, hint: dict) -> Optional[dict]:
|
||||
"""Check if error is database error, and ignore if so"""
|
||||
# pylint: disable=no-name-in-module
|
||||
|
|
|
@ -33,8 +33,8 @@ class PytestTestRunner: # pragma: no cover
|
|||
"outposts.container_image_base",
|
||||
f"ghcr.io/goauthentik/dev-%(type)s:{get_docker_tag()}",
|
||||
)
|
||||
CONFIG.y_set("error_reporting.sample_rate", 1.0)
|
||||
sentry_init(
|
||||
sample_rate=1.0,
|
||||
environment="testing",
|
||||
send_default_pii=True,
|
||||
)
|
||||
|
|
Reference in New Issue