Class ScopedThreadValue<T>

java.lang.Object
io.opentelemetry.instrumentation.api.internal.ScopedThreadValue<T>

public final class ScopedThreadValue<T> extends Object
Thread-local state for a lexical scope.

Each call to set(T) must be paired with restore(T) using the value returned by set, including when the scoped operation throws.

This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.

  • Constructor Details

    • ScopedThreadValue

      public ScopedThreadValue()
  • Method Details

    • get

      @Nullable public T get()
    • set

      @Nullable public T set(@Nullable T value)
      Sets the current value and returns the previous value to pass to restore(T) when the scope ends.
    • restore

      public void restore(@Nullable T previous)
      Restores the value returned by the matching call to set(T).