Repository: open-telemetry/opentelemetry-java
File: api/all/src/main/java/io/opentelemetry/api/GlobalOpenTelemetry.java (Java)

Code before:
   * <p>NOTE: This does not result in the {@link #set(OpenTelemetry)} side effects of {@link
   * #get()}.
   *
   * <p>Application custom instrumentation should use this method during initialization. See class
   * javadoc for more details.
   */
  public static OpenTelemetry getOrSet(Supplier<OpenTelemetry> supplier) {
    synchronized (mutex) {
      if (globalOpenTelemetry == null) {
        OpenTelemetry openTelemetry = supplier.get();
        set(openTelemetry);
        return openTelemetry;
      }
      return globalOpenTelemetry;
    }
  }

  /**
   * Returns the registered global {@link OpenTelemetry} if set, else calls {@link
   * GlobalOpenTelemetry#set(OpenTelemetry)} with a no-op {@link OpenTelemetry} instance and returns
   * that.
   *
   * <p>NOTE: all returned instanced are obfuscated to prevent callers from casting to SDK
   * implementation instances and inappropriately accessing non-instrumentation APIs.
   *
   * <p>Native instrumentations should use {@link #getOrNoop()} instad. See class javadoc for more
   * details.
   *
   * <p>Application custom instrumentation should use {@link #getOrSet(Supplier)} instead. See class
   * javadoc for more details.
   *
   * <p>If the global instance has not been set, and {@code
   * io.opentelemetry:opentelemetry-sdk-extension-autoconfigure} is present, and {@value
   * GLOBAL_AUTOCONFIGURE_ENABLED_PROPERTY} is {@code true}, the global instance will be set to an
   * autoconfigured instance instead of {@link OpenTelemetry#noop()}.
   *
   * @throws IllegalStateException if autoconfigure initialization is triggered and fails.
   */
  public static OpenTelemetry get() {
    OpenTelemetry openTelemetry = globalOpenTelemetry;
    if (openTelemetry == null) {
      synchronized (mutex) {
        openTelemetry = globalOpenTelemetry;
        if (openTelemetry == null) {

          OpenTelemetry autoConfigured = maybeAutoConfigureAndSetGlobal();
          if (autoConfigured != null) {
            return autoConfigured;
          }

          set(OpenTelemetry.noop());

Review comment (suggestion):
```suggestion
   * <p>Native instrumentations should use {@link #getOrNoop()} instead. See class javadoc for more
```

Code after:
      return globalOpenTelemetry != null;
    }
  }

  /**
   * Returns the registered global {@link OpenTelemetry} if set, else calls {@link
   * GlobalOpenTelemetry#set(OpenTelemetry)} with a no-op {@link OpenTelemetry} instance and returns
   * that.
   *
   * <p>NOTE: all returned instanced are obfuscated to prevent callers from casting to SDK
   * implementation instances and inappropriately accessing non-instrumentation APIs.
   *
   * <p>Native instrumentations should use {@link #getOrNoop()} instead. See class javadoc for more
   * details.
   *
   * <p>Application custom instrumentation should use {@link #isSet()} and only call this if the
   * response is {@code true}. See class javadoc for more details.
   *
   * <p>If the global instance has not been set, and {@code
   * io.opentelemetry:opentelemetry-sdk-extension-autoconfigure} is present, and {@value
   * GLOBAL_AUTOCONFIGURE_ENABLED_PROPERTY} is {@code true}, the global instance will be set to an
   * autoconfigured instance instead of {@link OpenTelemetry#noop()}.
   *
   * @throws IllegalStateException if autoconfigure initialization is triggered and fails.
   */
  public static OpenTelemetry get() {
    OpenTelemetry openTelemetry = globalOpenTelemetry;
    if (openTelemetry == null) {
      synchronized (mutex) {
        openTelemetry = globalOpenTelemetry;
        if (openTelemetry == null) {

          OpenTelemetry autoConfigured = maybeAutoConfigureAndSetGlobal();
          if (autoConfigured != null) {
            return autoConfigured;
          }

          set(OpenTelemetry.noop());
          openTelemetry = Objects.requireNonNull(globalOpenTelemetry);
        }
      }
    }
    return openTelemetry;
  }

  /**
   * Sets the {@link OpenTelemetry} that should be the global instance. Future calls to {@link
   * #get()} will return the provided {@link OpenTelemetry} instance. This should be called once as
   * early as possible in your application initialization logic, often in a {@code static} block in
   * your main class. It should only be called once - an attempt to call it a second time will
   * result in an error. If trying to set the global {@link OpenTelemetry} multiple times in tests,