Skip to content

Commit

Permalink
First attempt at configurable sample rate.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-wilfert committed Sep 12, 2024
1 parent 2ef1a08 commit f2592a1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions crates/symbolicator-service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PathBuf>,

// 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 {
Expand Down Expand Up @@ -556,6 +560,7 @@ impl Default for Config {
max_concurrent_requests: Some(200),
shared_cache: None,
_crash_db: None,
sample_rate: 0.05,
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions crates/symbolicator/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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
}
Expand Down
4 changes: 4 additions & 0 deletions local.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f2592a1

Please sign in to comment.