Package io.opencensus.tags.unsafe
Class ContextUtils
- java.lang.Object
-
- io.opencensus.tags.unsafe.ContextUtils
-
public final class ContextUtils extends java.lang.ObjectUtility methods for accessing theTagContextcontained in theContext.Most code should interact with the current context via the public APIs in
TagContextand avoid accessingTAG_CONTEXT_KEYdirectly.- Since:
- 0.8
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classContextUtils.EmptyTagContext
-
Field Summary
Fields Modifier and Type Field Description private static TagContextEMPTY_TAG_CONTEXTprivate static io.grpc.Context.Key<TagContext>TAG_CONTEXT_KEYTheContext.Keyused to interact with theTagContextcontained in theContext.
-
Constructor Summary
Constructors Modifier Constructor Description privateContextUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static TagContextgetValue(io.grpc.Context context)Returns the value from the specifiedContext.static io.grpc.ContextwithValue(io.grpc.Context context, TagContext tagContext)Creates a newContextwith the given value set.
-
-
-
Field Detail
-
EMPTY_TAG_CONTEXT
private static final TagContext EMPTY_TAG_CONTEXT
-
TAG_CONTEXT_KEY
private static final io.grpc.Context.Key<TagContext> TAG_CONTEXT_KEY
TheContext.Keyused to interact with theTagContextcontained in theContext.
-
-
Method Detail
-
withValue
public static io.grpc.Context withValue(io.grpc.Context context, @Nullable TagContext tagContext)Creates a newContextwith the given value set.- Parameters:
context- the parentContext.tagContext- the value to be set.- Returns:
- a new context with the given value set.
- Since:
- 0.21
-
getValue
public static TagContext getValue(io.grpc.Context context)
Returns the value from the specifiedContext.- Parameters:
context- the specifiedContext.- Returns:
- the value from the specified
Context. - Since:
- 0.21
-
-