From f2592a1cabf9c4d18bdfdc29567257298da6b908 Mon Sep 17 00:00:00 2001 From: tobias-wilfert Date: Thu, 12 Sep 2024 09:11:28 +0200 Subject: [PATCH 1/3] First attempt at configurable sample rate. --- crates/symbolicator-service/src/config.rs | 5 +++++ crates/symbolicator/src/cli.rs | 7 +++++-- local.example.yml | 4 ++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/symbolicator-service/src/config.rs b/crates/symbolicator-service/src/config.rs index 4952ca033..79d6fbfb9 100644 --- a/crates/symbolicator-service/src/config.rs +++ b/crates/symbolicator-service/src/config.rs @@ -473,6 +473,10 @@ pub struct Config { /// cached on disk. The path is created if it doesn't exist. Path must be UTF-8. #[serde(default)] pub _crash_db: Option, + + // TODO: 1) Discuss the name for this, currently the name in the sdk, not sure if that is what we want + // TODO: 2) Add documentation to this explaining nicely what ir does. + pub sample_rate: f32, } impl Config { @@ -556,6 +560,7 @@ impl Default for Config { max_concurrent_requests: Some(200), shared_cache: None, _crash_db: None, + sample_rate: 0.05, } } } diff --git a/crates/symbolicator/src/cli.rs b/crates/symbolicator/src/cli.rs index bda3a4196..c8de7396d 100644 --- a/crates/symbolicator/src/cli.rs +++ b/crates/symbolicator/src/cli.rs @@ -87,7 +87,7 @@ pub fn execute() -> Result<()> { release, session_mode: sentry::SessionMode::Request, auto_session_tracking: false, - traces_sampler: Some(Arc::new(|ctx| { + traces_sampler: Some(Arc::new(move |ctx| { if Some(true) == ctx.sampled() { 1.0 } else if ctx.operation() != "http.server" { @@ -100,7 +100,10 @@ pub fn execute() -> Result<()> { // we end up with ~200 sampled transactions per second, or ~12_000 per minute. // We only do this for the "real" transactions and not the http frontend that // just spawns these computations. - 0.05 + + // TODO: Think about if moving the the above comment to the Config is now more + // appropriate? + config.sample_rate } else { 0.0 } diff --git a/local.example.yml b/local.example.yml index a420974b5..895547983 100644 --- a/local.example.yml +++ b/local.example.yml @@ -13,6 +13,10 @@ cache_dir: cache logging: level: error +# TODO: Add some documentation for this here. +# The sample rate for event submission. (0.0 - 1.0, defaults to 0.05) +sample_rate: 0.05 + # Configure some default symbol sources: sources: # You can use symsorter to correctly sort symbols into the local filesystem source: From aa9c204f6a34e97ac0c62e4586fda7a6b55ddcf9 Mon Sep 17 00:00:00 2001 From: tobias-wilfert Date: Thu, 12 Sep 2024 10:06:51 +0200 Subject: [PATCH 2/3] Updated name of configuration option and improved documentation. --- crates/symbolicator-service/src/config.rs | 7 +++---- crates/symbolicator/src/cli.rs | 5 ++--- local.example.yml | 5 ++--- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/crates/symbolicator-service/src/config.rs b/crates/symbolicator-service/src/config.rs index 79d6fbfb9..d7b6d6bf4 100644 --- a/crates/symbolicator-service/src/config.rs +++ b/crates/symbolicator-service/src/config.rs @@ -474,9 +474,8 @@ pub struct Config { #[serde(default)] pub _crash_db: Option, - // TODO: 1) Discuss the name for this, currently the name in the sdk, not sure if that is what we want - // TODO: 2) Add documentation to this explaining nicely what ir does. - pub sample_rate: f32, + /// The sample rate for transactions. (0.0 - 1.0, defaults to 0.05) + pub transaction_sample_rate: f32, } impl Config { @@ -560,7 +559,7 @@ impl Default for Config { max_concurrent_requests: Some(200), shared_cache: None, _crash_db: None, - sample_rate: 0.05, + transaction_sample_rate: 0.05, } } } diff --git a/crates/symbolicator/src/cli.rs b/crates/symbolicator/src/cli.rs index c8de7396d..f0a17ed14 100644 --- a/crates/symbolicator/src/cli.rs +++ b/crates/symbolicator/src/cli.rs @@ -91,6 +91,7 @@ pub fn execute() -> Result<()> { if Some(true) == ctx.sampled() { 1.0 } else if ctx.operation() != "http.server" { + // TODO: Think about what to do with this comment now: // Symbolicator receives at peak: // - ~3_000 `symbolicate_js`, // - ~800 `symbolicater`, and @@ -101,9 +102,7 @@ pub fn execute() -> Result<()> { // We only do this for the "real" transactions and not the http frontend that // just spawns these computations. - // TODO: Think about if moving the the above comment to the Config is now more - // appropriate? - config.sample_rate + config.transaction_sample_rate } else { 0.0 } diff --git a/local.example.yml b/local.example.yml index 895547983..0a47f1858 100644 --- a/local.example.yml +++ b/local.example.yml @@ -13,9 +13,8 @@ cache_dir: cache logging: level: error -# TODO: Add some documentation for this here. -# The sample rate for event submission. (0.0 - 1.0, defaults to 0.05) -sample_rate: 0.05 +# The sample rate for transactions. (0.0 - 1.0, defaults to 0.05) +transaction_sample_rate: 0.05 # Configure some default symbol sources: sources: From 588d6fd65732b1979911e0f662dd17c20f4dd5ae Mon Sep 17 00:00:00 2001 From: tobias-wilfert Date: Thu, 12 Sep 2024 10:43:16 +0200 Subject: [PATCH 3/3] Moved comment and updated changelog. --- CHANGELOG.md | 1 + crates/symbolicator-service/src/config.rs | 9 +++++++++ crates/symbolicator/src/cli.rs | 11 ----------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67677a00e..216cdf7e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Various fixes & improvements +- Transaction sample rate is now configurable through the config file ([#1517](https://github.com/getsentry/symbolicator/pull/1517)). - In native symbolication, trying to download a source file from a sourcelink now creates a candidate ([#1507](https://github.com/getsentry/symbolicator/pull/1510)). diff --git a/crates/symbolicator-service/src/config.rs b/crates/symbolicator-service/src/config.rs index d7b6d6bf4..eb6b72028 100644 --- a/crates/symbolicator-service/src/config.rs +++ b/crates/symbolicator-service/src/config.rs @@ -559,6 +559,15 @@ impl Default for Config { max_concurrent_requests: Some(200), shared_cache: None, _crash_db: None, + // Symbolicator receives at peak: + // - ~3_000 `symbolicate_js`, + // - ~800 `symbolicater`, and + // - ~40 `minidump_stackwalk` requests per second. + // + // round that up to ~4_000 total requests per second, with a 5% sample rate, + // we end up with ~200 sampled transactions per second, or ~12_000 per minute. + // We only do this for the "real" transactions and not the http frontend that + // just spawns these computations. transaction_sample_rate: 0.05, } } diff --git a/crates/symbolicator/src/cli.rs b/crates/symbolicator/src/cli.rs index f0a17ed14..fd4555194 100644 --- a/crates/symbolicator/src/cli.rs +++ b/crates/symbolicator/src/cli.rs @@ -91,17 +91,6 @@ pub fn execute() -> Result<()> { if Some(true) == ctx.sampled() { 1.0 } else if ctx.operation() != "http.server" { - // TODO: Think about what to do with this comment now: - // Symbolicator receives at peak: - // - ~3_000 `symbolicate_js`, - // - ~800 `symbolicater`, and - // - ~40 `minidump_stackwalk` requests per second. - // - // round that up to ~4_000 total requests per second, with a 5% sample rate, - // we end up with ~200 sampled transactions per second, or ~12_000 per minute. - // We only do this for the "real" transactions and not the http frontend that - // just spawns these computations. - config.transaction_sample_rate } else { 0.0