Skip to content

Commit 8b6823c

Browse files
authored
chore: filter out health checks (#76)
* chore: filter out health checks Sentry currently reports over 790k transactions per week, generated by `kube-probe` health checks. This increases outbound network traffic, and isn't very helpful. Signed-off-by: Mike Fiedler <[email protected]> * chore: ignore compiled cache files Signed-off-by: Mike Fiedler <[email protected]> --------- Signed-off-by: Mike Fiedler <[email protected]>
1 parent 9c4d5c5 commit 8b6823c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.state/
2+
__pycache__/

inspector/main.py

+13
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,24 @@
1212

1313
from .legacy import parse
1414

15+
16+
def traces_sampler(sampling_context):
17+
"""
18+
Filter out noisy transactions.
19+
See https://github.com/getsentry/sentry-python/discussions/1569
20+
"""
21+
path = sampling_context.get("wsgi_environ", {}).get("PATH_INFO", None)
22+
if path and path == "/_health/":
23+
return 0
24+
return 1
25+
26+
1527
if SENTRY_DSN := os.environ.get("SENTRY_DSN"):
1628
sentry_sdk.init(
1729
dsn=SENTRY_DSN,
1830
integrations=[FlaskIntegration()],
1931
traces_sample_rate=1.0,
32+
traces_sampler=traces_sampler,
2033
)
2134

2235
app = Flask(__name__)

0 commit comments

Comments
 (0)