Package org.springframework.cloud.sleuth
Interface BaggageInScope
-
- All Superinterfaces:
AutoCloseable,Closeable
public interface BaggageInScope extends Closeable
Inspired by OpenZipkin Brave'sBaggageField. 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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Stringget()Stringget(TraceContext traceContext)Retrieves baggage from the givenTraceContext.BaggageInScopemakeCurrent()Sets the current baggage in scope.Stringname()BaggageInScopeset(String value)Sets the baggage value.BaggageInScopeset(TraceContext traceContext, String value)Sets the baggage value for the givenTraceContext.
-
-
-
Method Detail
-
name
String name()
- Returns:
- name of the baggage entry
-
get
@Nullable String get()
- Returns:
- value of the baggage entry or
nullif not set.
-
get
@Nullable String get(TraceContext traceContext)
Retrieves baggage from the givenTraceContext.- Parameters:
traceContext- context containing baggage- Returns:
- value of the baggage entry or
nullif not set.
-
set
BaggageInScope set(String value)
Sets the baggage value.- Parameters:
value- to set- Returns:
- new scope
-
set
BaggageInScope set(TraceContext traceContext, String value)
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
-
-