TagContext
class TagContext
TagContext represents a collection of tags.
A TagContext can be used to label anything that is associated with a specific operation, such as an HTTP request. Each tag is composed of a key (TagKey), and a value (TagValue). A TagContext represents a map from keys to values, i.e., each key is associated with exactly one value, but multiple keys can be associated with the same value. TagContext is serializable, and it represents all of the information that must be propagated across process boundaries.
Traits
Constants
CTX_KEY |
The key used for storing and retrieving a TagContext object from Context. |
MAX_LENGTH |
The maximum length for a serialized TagContext. |
EX_INVALID_CONTEXT |
Invalid Context Error message |
Methods
Serializes the TagContext to a string representation.
Returns an array of Tag objects this map holds.
Returns an empty YagContext object.
Details
at line 61
final string
value(TagKey $key)
Returns the value for the key if a value for the key exists.
at line 74
final bool
insert(TagKey $key, TagValue $value)
Insert a Tag into TagContext given provided TagKey and string value.
If TagKey already exists in TagContext this method is a noop.
at line 92
final bool
update(TagKey $key, TagValue $value)
Update a Tag into TagContext given provided TagKey with string value.
If TagKey does not exist in TagContext this method is a noop.
at line 109
final
upsert(TagKey $key, TagValue $value)
Insert or Update a Tag into TagContext given provided TagKey with provided string value.
at line 120
final bool
delete(TagKey $key)
Deletes Tag from TagContext identified by its TagKey.
at line 135
final string
__toString()
Serializes the TagContext to a string representation.
at line 151
final array
tags()
Returns an array of Tag objects this map holds.
at line 161
final static TagContext
empty()
Returns an empty YagContext object.
at line 173
final static TagContext
fromContext(Context $ctx = null)
Extract a TagContext from the provided Context object.
If Context is not provided, the current Context is used. If no TagContext is found, a new empty TagContext is returned.
at line 189
final static TagContext
new(Context $ctx = null)
Copy and return the TagContext as found in the provided Context object.
If Context is not provided, the current Context is used. If no TagContext is found, a new empty TagContext is returned.
at line 202
final Context
newContext(Context $ctx = null)
Creates a new Context with our TagContext attached.
To propagate a TagContext to downstream methods and downstream RPCs, add a TagContext to the current Context. If there is already a TagContext in the current context, it will be replaced with this TagContext.