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"""
|
"""Configure sentry SDK"""
|
||||||
sentry_env = CONFIG.y("error_reporting.environment", "customer")
|
sentry_env = CONFIG.y("error_reporting.environment", "customer")
|
||||||
kwargs = {
|
kwargs = {
|
||||||
"traces_sample_rate": float(CONFIG.y("error_reporting.sample_rate", 0.5)),
|
|
||||||
"environment": sentry_env,
|
"environment": sentry_env,
|
||||||
"send_default_pii": CONFIG.y_bool("error_reporting.send_pii", False),
|
"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),
|
ThreadingIntegration(propagate_hub=True),
|
||||||
],
|
],
|
||||||
before_send=before_send,
|
before_send=before_send,
|
||||||
|
traces_sampler=traces_sampler,
|
||||||
release=f"authentik@{__version__}",
|
release=f"authentik@{__version__}",
|
||||||
**kwargs,
|
**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]:
|
def before_send(event: dict, hint: dict) -> Optional[dict]:
|
||||||
"""Check if error is database error, and ignore if so"""
|
"""Check if error is database error, and ignore if so"""
|
||||||
# pylint: disable=no-name-in-module
|
# pylint: disable=no-name-in-module
|
||||||
|
|
|
@ -33,8 +33,8 @@ class PytestTestRunner: # pragma: no cover
|
||||||
"outposts.container_image_base",
|
"outposts.container_image_base",
|
||||||
f"ghcr.io/goauthentik/dev-%(type)s:{get_docker_tag()}",
|
f"ghcr.io/goauthentik/dev-%(type)s:{get_docker_tag()}",
|
||||||
)
|
)
|
||||||
|
CONFIG.y_set("error_reporting.sample_rate", 1.0)
|
||||||
sentry_init(
|
sentry_init(
|
||||||
sample_rate=1.0,
|
|
||||||
environment="testing",
|
environment="testing",
|
||||||
send_default_pii=True,
|
send_default_pii=True,
|
||||||
)
|
)
|
||||||
|
|
Reference in New Issue