Fix native mode error cause by static init of random (#862)

This commit is contained in:
Bruno Baptista 2024-09-16 18:26:53 +01:00 committed by GitHub
parent 0edcfae368
commit ca609c8999
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -28,6 +28,7 @@ import java.util.Set;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.logging.Level;
@ -40,7 +41,6 @@ public final class AwsXrayRemoteSampler implements Sampler, Closeable {
static final long DEFAULT_TARGET_INTERVAL_NANOS = TimeUnit.SECONDS.toNanos(10);
private static final Random RANDOM = new Random();
private static final Logger logger = Logger.getLogger(AwsXrayRemoteSampler.class.getName());
private final Resource resource;
@ -97,7 +97,7 @@ public final class AwsXrayRemoteSampler implements Sampler, Closeable {
this.pollingIntervalNanos = pollingIntervalNanos;
// Add ~1% of jitter
jitterNanos = RANDOM.longs(0, pollingIntervalNanos / 100).iterator();
jitterNanos = ThreadLocalRandom.current().longs(0, pollingIntervalNanos / 100).iterator();
// Execute first update right away on the executor thread.
executor.execute(this::getAndUpdateSampler);