Class ContextUtils
java.lang.Object
io.opencensus.tags.unsafe.ContextUtils
Utility methods for accessing the
TagContext contained in the Context.
Most code should interact with the current context via the public APIs in TagContext and avoid accessing TAG_CONTEXT_KEY directly.
- Since:
- 0.8
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final TagContextprivate static final io.grpc.Context.Key<TagContext> TheContext.Keyused to interact with theTagContextcontained in theContext. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 Details
-
EMPTY_TAG_CONTEXT
-
TAG_CONTEXT_KEY
TheContext.Keyused to interact with theTagContextcontained in theContext.
-
-
Constructor Details
-
ContextUtils
private ContextUtils()
-
-
Method Details
-
withValue
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
Returns the value from the specifiedContext.- Parameters:
context- the specifiedContext.- Returns:
- the value from the specified
Context. - Since:
- 0.21
-