Package org.springframework.cloud.sleuth
Interface BaggageInScope
- All Superinterfaces:
AutoCloseable,Closeable
Inspired by OpenZipkin Brave's
BaggageField. Since some tracer implementations
require a scope to be wrapped around baggage, baggage must be closed so that the scope
does not leak. Some tracer implementations make baggage immutable (e.g. OpenTelemetry),
so when the value gets updated they might create new scope (others will return the same
one - e.g. OpenZipkin Brave).
Represents a single baggage entry.- Since:
- 3.0.0
- Author:
- Marcin Grzejszczak
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()get()get(TraceContext traceContext) Retrieves baggage from the givenTraceContext.Sets the current baggage in scope.name()Sets the baggage value.set(TraceContext traceContext, String value) Sets the baggage value for the givenTraceContext.
-
Method Details
-
name
String name()- Returns:
- name of the baggage entry
-
get
- Returns:
- value of the baggage entry or
nullif not set.
-
get
Retrieves baggage from the givenTraceContext.- Parameters:
traceContext- context containing baggage- Returns:
- value of the baggage entry or
nullif not set.
-
set
Sets the baggage value.- Parameters:
value- to set- Returns:
- new scope
-
set
Sets the baggage value for the givenTraceContext.- Parameters:
traceContext- context containing baggagevalue- to set- Returns:
- new scope
-
makeCurrent
BaggageInScope makeCurrent()Sets the current baggage in scope.- Returns:
- this in scope
-
close
void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-