From f2592a1cabf9c4d18bdfdc29567257298da6b908 Mon Sep 17 00:00:00 2001 From: tobias-wilfert Date: Thu, 12 Sep 2024 09:11:28 +0200 Subject: [PATCH] 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: