18
18
import io .sentry .util .HintUtils ;
19
19
import io .sentry .util .Objects ;
20
20
import io .sentry .util .Random ;
21
+ import io .sentry .util .SentryRandom ;
21
22
import io .sentry .util .TracingUtils ;
22
23
import java .io .Closeable ;
23
24
import java .io .IOException ;
@@ -40,7 +41,6 @@ public final class SentryClient implements ISentryClient, IMetricsClient {
40
41
41
42
private final @ NotNull SentryOptions options ;
42
43
private final @ NotNull ITransport transport ;
43
- private final @ Nullable Random random ;
44
44
private final @ NotNull SortBreadcrumbsByDate sortBreadcrumbsByDate = new SortBreadcrumbsByDate ();
45
45
private final @ NotNull IMetricsAggregator metricsAggregator ;
46
46
@@ -66,8 +66,6 @@ public boolean isEnabled() {
66
66
options .isEnableMetrics ()
67
67
? new MetricsAggregator (options , this )
68
68
: NoopMetricsAggregator .getInstance ();
69
-
70
- this .random = options .getSampleRate () == null ? null : new Random ();
71
69
}
72
70
73
71
private boolean shouldApplyScopeData (
@@ -1183,6 +1181,7 @@ public boolean isHealthy() {
1183
1181
}
1184
1182
1185
1183
private boolean sample () {
1184
+ final @ Nullable Random random = options .getSampleRate () == null ? null : SentryRandom .current ();
1186
1185
// https://docs.sentry.io/development/sdk-dev/features/#event-sampling
1187
1186
if (options .getSampleRate () != null && random != null ) {
1188
1187
final double sampling = options .getSampleRate ();
0 commit comments