Skip to content

Commit 03b0fc8

Browse files
committed
sentry: Reduce trace sample rate for download endpoint
1 parent 401fa88 commit 03b0fc8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Diff for: src/sentry/mod.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,18 @@ pub fn init() -> ClientInitGuard {
2929

3030
let traces_sample_rate = env_optional("SENTRY_TRACES_SAMPLE_RATE").unwrap_or(0.0);
3131

32-
let traces_sampler = move |_ctx: &TransactionContext| -> f32 { traces_sample_rate };
32+
let traces_sampler = move |ctx: &TransactionContext| -> f32 {
33+
let is_download_endpoint =
34+
ctx.name().starts_with("/api/v1/crates/") && ctx.name().ends_with("/download");
35+
36+
if is_download_endpoint {
37+
// Reduce the sample rate for the download endpoint, since we have significantly
38+
// more traffic on that endpoint compared to the rest
39+
traces_sample_rate / 10.
40+
} else {
41+
traces_sample_rate
42+
}
43+
};
3344

3445
let opts = ClientOptions {
3546
auto_session_tracking: true,

0 commit comments

Comments
 (0)