Package io.opentelemetry.api.baggage
Interface BaggageBuilder
-
public interface BaggageBuilderA builder ofBaggage.- See Also:
Baggage.builder()
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Baggagebuild()Creates aBaggagefrom this builder.default BaggageBuilderput(String key, String value)Adds the key/value pair with empty metadata regardless of whether the key is present.BaggageBuilderput(String key, String value, BaggageEntryMetadata entryMetadata)Adds the key/value pair and metadata regardless of whether the key is present.BaggageBuilderremove(String key)Removes the key if it exists.BaggageBuildersetNoParent()Sets the option to become a rootBaggagewith no parent.BaggageBuildersetParent(io.opentelemetry.context.Context context)Sets the parentBaggageto use from the specifiedContext.
-
-
-
Method Detail
-
setParent
BaggageBuilder setParent(io.opentelemetry.context.Context context)
Sets the parentBaggageto use from the specifiedContext. If no parentBaggageis provided, the value ofBaggage.current()atbuild()time will be used as parent, unlesssetNoParent()was called.If no parent
Baggageis available in the specifiedContext, the resultingBaggagewill become a root instance, as ifsetNoParent()had been called.This must be used to create a
Baggagewhen manual Context propagation is used.If called multiple times, only the last specified value will be used.
- Parameters:
context- theContext.- Returns:
- this.
- Throws:
NullPointerException- ifcontextisnull.- See Also:
setNoParent()
-
setNoParent
BaggageBuilder setNoParent()
Sets the option to become a rootBaggagewith no parent. If not called, the value provided usingsetParent(Context)or otherwiseBaggage.current()atbuild()time will be used as parent.- Returns:
- this.
-
put
BaggageBuilder put(String key, String value, BaggageEntryMetadata entryMetadata)
Adds the key/value pair and metadata regardless of whether the key is present.- Parameters:
key- theStringkey which will be set.value- theStringvalue to set for the given key.entryMetadata- theBaggageEntryMetadatametadata to set for the given key.- Returns:
- this
-
put
default BaggageBuilder put(String key, String value)
Adds the key/value pair with empty metadata regardless of whether the key is present.- Parameters:
key- theStringkey which will be set.value- theStringvalue to set for the given key.- Returns:
- this
-
remove
BaggageBuilder remove(String key)
Removes the key if it exists.- Parameters:
key- theStringkey which will be removed.- Returns:
- this
-
build
Baggage build()
Creates aBaggagefrom this builder.- Returns:
- a
Baggagewith the same entries as this builder.
-
-