Class ArrayBasedContext
java.lang.Object
io.opentelemetry.context.ArrayBasedContext
- All Implemented Interfaces:
Context
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<V> Vget(ContextKey<V> key) Returns the value stored in thisContextfor the givenContextKey, ornullif there is no value for the key in this context.(package private) static Contextroot()toString()<V> Contextwith(ContextKey<V> key, V value) Returns a new context with the given key value set.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Context
makeCurrent, with, wrap, wrap, wrap, wrap, wrap, wrapConsumer, wrapConsumer, wrapFunction, wrapFunction, wrapSupplier
-
Field Details
-
ROOT
-
entries
-
-
Constructor Details
-
ArrayBasedContext
-
-
Method Details
-
root
-
get
Description copied from interface:ContextReturns the value stored in thisContextfor the givenContextKey, ornullif there is no value for the key in this context. -
with
Description copied from interface:ContextReturns a new context with the given key value set.Context withCredential = Context.current().with(CRED_KEY, cred); withCredential.wrap(new Runnable() { public void run() { readUserRecords(userId, CRED_KEY.get()); } }).run();Note that multiple calls to
Context.with(ContextKey, Object)can be chained together.context.with(K1, V1).with(K2, V2);Nonetheless,
Contextshould not be treated like a general purpose map with a large number of keys and values — combine multiple related items together into a single key instead of separating them. But if the items are unrelated, have separate keys for them. -
toString
-