Skip to content

Commit

Permalink
sentry: Reduce trace sample rate for download endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed Nov 5, 2022
1 parent f475a7a commit 91d8a9a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/sentry/mod.rs
Expand Up @@ -29,7 +29,18 @@ pub fn init() -> ClientInitGuard {

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

let traces_sampler = move |_ctx: &TransactionContext| -> f32 { traces_sample_rate };
let traces_sampler = move |ctx: &TransactionContext| -> f32 {
let is_download_endpoint =
ctx.name.starts_with("/api/v1/crates/") && ctx.name.ends_with("/download");

if is_download_endpoint {
// Reduce the sample rate for the download endpoint, since we have significantly
// more traffic on that endpoint compared to the rest
traces_sample_rate / 10
} else {
traces_sample_rate
}
};

let opts = ClientOptions {
auto_session_tracking: true,
Expand Down

0 comments on commit 91d8a9a

Please sign in to comment.