Package io.opentelemetry.api.baggage
Interface Baggage.Builder
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Baggage
build()
Creates aBaggage
from this builder.Baggage.Builder
put(String key, String value)
Adds the key/value pair with empty metadata regardless of whether the key is present.Baggage.Builder
put(String key, String value, EntryMetadata entryMetadata)
Adds the key/value pair and metadata regardless of whether the key is present.Baggage.Builder
remove(String key)
Removes the key if it exists.Baggage.Builder
setNoParent()
Sets the option to become a rootBaggage
with no parent.Baggage.Builder
setParent(io.opentelemetry.context.Context context)
Sets the parentBaggage
to use from the specifiedContext
.
-
-
-
Method Detail
-
setParent
Baggage.Builder setParent(io.opentelemetry.context.Context context)
Sets the parentBaggage
to use from the specifiedContext
. If no parentBaggage
is provided, the value ofBaggage.current()
atbuild()
time will be used as parent, unlesssetNoParent()
was called.If no parent
Baggage
is available in the specifiedContext
, the resultingBaggage
will become a root instance, as ifsetNoParent()
had been called.This must be used to create a
Baggage
when manual Context propagation is used.If called multiple times, only the last specified value will be used.
- Parameters:
context
- theContext
.- Returns:
- this.
- Throws:
NullPointerException
- ifcontext
isnull
.- See Also:
setNoParent()
-
setNoParent
Baggage.Builder setNoParent()
Sets the option to become a rootBaggage
with no parent. If not called, the value provided usingsetParent(Context)
or otherwiseBaggage.current()
atbuild()
time will be used as parent.- Returns:
- this.
-
put
Baggage.Builder put(String key, String value, EntryMetadata entryMetadata)
Adds the key/value pair and metadata regardless of whether the key is present.- Parameters:
key
- theString
key which will be set.value
- theString
value to set for the given key.entryMetadata
- theEntryMetadata
associated with thisEntry
.- Returns:
- this
-
put
Baggage.Builder put(String key, String value)
Adds the key/value pair with empty metadata regardless of whether the key is present.- Parameters:
key
- theString
key which will be set.value
- theString
value to set for the given key.- Returns:
- this
-
remove
Baggage.Builder remove(String key)
Removes the key if it exists.- Parameters:
key
- theString
key which will be removed.- Returns:
- this
-
build
Baggage build()
Creates aBaggage
from this builder.- Returns:
- a
Baggage
with the same entries as this builder.
-
-