diff --git a/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/AwsXrayRemoteSampler.java b/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/AwsXrayRemoteSampler.java index 4ab156b4b..9b5a2e7e6 100644 --- a/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/AwsXrayRemoteSampler.java +++ b/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/AwsXrayRemoteSampler.java @@ -28,6 +28,7 @@ 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 static AwsXrayRemoteSamplerBuilder newBuilder(Resource resource) { 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);