Package io.opentelemetry.api.baggage
Interface Baggage
-
- All Superinterfaces:
io.opentelemetry.context.ImplicitContextKeyed
@Immutable public interface Baggage extends io.opentelemetry.context.ImplicitContextKeyedA map fromStringtoStringandEntryMetadatathat can be used to label anything that is associated with a specific operation.For example,
Baggages can be used to label stats, log messages, or debugging information.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceBaggage.BuilderBuilder for theBaggageclass.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static Baggage.Builderbuilder()Creates a newBaggage.Builderfor creating Baggage.static Baggagecurrent()Returns Baggage from the currentContext, falling back to empty Baggage if none is in the current Context.static Baggageempty()Baggage with no entries.voidforEach(BaggageConsumer consumer)Iterates over all the entries in thisBaggage.static BaggagefromContext(io.opentelemetry.context.Context context)static BaggagefromContextOrNull(io.opentelemetry.context.Context context)StringgetEntryValue(String entryKey)Returns theStringvalue associated with the given key, without metadata.default booleanisEmpty()Returns whether thisBaggageis empty, containing no entries.intsize()Returns the number of entries in thisBaggage.default io.opentelemetry.context.ContextstoreInContext(io.opentelemetry.context.Context context)Baggage.BuildertoBuilder()Create a Builder pre-initialized with the contents of this Baggage.
-
-
-
Method Detail
-
empty
static Baggage empty()
Baggage with no entries.
-
builder
static Baggage.Builder builder()
Creates a newBaggage.Builderfor creating Baggage.
-
current
static Baggage current()
Returns Baggage from the currentContext, falling back to empty Baggage if none is in the current Context.
-
fromContext
static Baggage fromContext(io.opentelemetry.context.Context context)
-
fromContextOrNull
@Nullable static Baggage fromContextOrNull(io.opentelemetry.context.Context context)
-
storeInContext
default io.opentelemetry.context.Context storeInContext(io.opentelemetry.context.Context context)
- Specified by:
storeInContextin interfaceio.opentelemetry.context.ImplicitContextKeyed
-
size
int size()
Returns the number of entries in thisBaggage.
-
isEmpty
default boolean isEmpty()
Returns whether thisBaggageis empty, containing no entries.
-
forEach
void forEach(BaggageConsumer consumer)
Iterates over all the entries in thisBaggage.
-
getEntryValue
@Nullable String getEntryValue(String entryKey)
Returns theStringvalue associated with the given key, without metadata.- Parameters:
entryKey- entry key to return the value for.- Returns:
- the value associated with the given key, or
nullif noEntrywith the givenentryKeyis in thisBaggage.
-
toBuilder
Baggage.Builder toBuilder()
Create a Builder pre-initialized with the contents of this Baggage. The returned Builder will be set to not use an implicit parent, so any parent assignment must be done manually.
-
-