Package io.opentelemetry.api.trace
Class TraceState
- java.lang.Object
-
- io.opentelemetry.api.trace.TraceState
-
@Immutable public abstract class TraceState extends Object
Carries tracing-system specific context in a list of key-value pairs. TraceState allows different vendors propagate additional information and inter-operate with their legacy Id formats.Implementation is optimized for a small list of key-value pairs.
Key is opaque string up to 256 characters printable. It MUST begin with a lowercase letter, and can only contain lowercase letters a-z, digits 0-9, underscores _, dashes -, asterisks *, and forward slashes /.
Value is opaque string up to 256 characters printable ASCII RFC0020 characters (i.e., the range 0x20 to 0x7E) except comma , and =.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TraceState.Builder
Builder class forTraceState
.
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_VENDOR_ID_SIZE
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TraceState.Builder
builder()
Returns aBuilder
based on an emptyTraceState
.void
forEach(BiConsumer<String,String> consumer)
Iterates over all the key-value entries contained in thisTraceState
.String
get(String key)
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.static TraceState
getDefault()
Returns the defaultTraceState
with no entries.boolean
isEmpty()
Returns whether thisTraceState
is empty, containing no entries.int
size()
Returns the number of entries in thisTraceState
.TraceState.Builder
toBuilder()
Returns aBuilder
based on thisTraceState
.
-
-
-
Field Detail
-
MAX_VENDOR_ID_SIZE
public static final int MAX_VENDOR_ID_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDefault
public static TraceState getDefault()
Returns the defaultTraceState
with no entries.- Returns:
- the default
TraceState
.
-
get
@Nullable public String get(String key)
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.- Parameters:
key
- with which the specified value is to be associated- Returns:
- the value to which the specified key is mapped, or null if this map contains no mapping for the key.
-
size
public int size()
Returns the number of entries in thisTraceState
.
-
isEmpty
public boolean isEmpty()
Returns whether thisTraceState
is empty, containing no entries.
-
forEach
public void forEach(BiConsumer<String,String> consumer)
Iterates over all the key-value entries contained in thisTraceState
.
-
builder
public static TraceState.Builder builder()
Returns aBuilder
based on an emptyTraceState
.- Returns:
- a
Builder
based on an emptyTraceState
.
-
toBuilder
public TraceState.Builder toBuilder()
Returns aBuilder
based on thisTraceState
.- Returns:
- a
Builder
based on thisTraceState
.
-
-