All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.opentelemetry.opencensusshim.ThreadLocalRandomHandler Maven / Gradle / Ivy

The newest version!
/*
 * Copyright The OpenTelemetry Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package io.opentelemetry.opencensusshim;

import io.opencensus.implcore.trace.internal.RandomHandler;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import javax.annotation.concurrent.ThreadSafe;

/**
 * Implementation of the {@link RandomHandler} using {@link ThreadLocalRandom}. There is an existing
 * implementation in opencensus-impl, however we do not want to depend on opencensus-impl here.
 */
@ThreadSafe
final class ThreadLocalRandomHandler extends RandomHandler {

  /** Constructs a new {@code ThreadLocalRandomHandler}. */
  ThreadLocalRandomHandler() {}

  @Override
  public Random current() {
    return ThreadLocalRandom.current();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy