Skip to content

Commit

Permalink
Fix native mode error cause by static init of random (open-telemetry#862
Browse files Browse the repository at this point in the history
)
  • Loading branch information
brunobat authored and robsunday committed Sep 17, 2024
1 parent 5ffa348 commit eb5dc6f
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit eb5dc6f

Please sign in to comment.