Skip to content

Commit f475a7a

Browse files
committed
sentry: Implement basic traces_sampler function
1 parent b2bab4b commit f475a7a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Diff for: src/sentry/mod.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ mod middleware;
22

33
use crate::env_optional;
44
pub use middleware::CustomSentryMiddleware as SentryMiddleware;
5-
use sentry::{ClientInitGuard, ClientOptions, IntoDsn};
5+
use sentry::{ClientInitGuard, ClientOptions, IntoDsn, TransactionContext};
6+
use std::sync::Arc;
67

78
/// Initializes the Sentry SDK from the environment variables.
89
///
@@ -28,13 +29,15 @@ pub fn init() -> ClientInitGuard {
2829

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

32+
let traces_sampler = move |_ctx: &TransactionContext| -> f32 { traces_sample_rate };
33+
3134
let opts = ClientOptions {
3235
auto_session_tracking: true,
3336
dsn,
3437
environment,
3538
release,
3639
session_mode: sentry::SessionMode::Request,
37-
traces_sample_rate,
40+
traces_sampler: Some(Arc::new(traces_sampler)),
3841
..Default::default()
3942
};
4043

0 commit comments

Comments
 (0)