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 classTraceState.BuilderBuilder class forTraceState.
-
Field Summary
Fields Modifier and Type Field Description static intMAX_VENDOR_ID_SIZE
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TraceState.Builderbuilder()Returns aBuilderbased on an emptyTraceState.voidforEach(BiConsumer<String,String> consumer)Iterates over all the key-value entries contained in thisTraceState.Stringget(String key)Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.static TraceStategetDefault()Returns the defaultTraceStatewith no entries.booleanisEmpty()Returns whether thisTraceStateis empty, containing no entries.intsize()Returns the number of entries in thisTraceState.TraceState.BuildertoBuilder()Returns aBuilderbased 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 defaultTraceStatewith 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 thisTraceStateis 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 aBuilderbased on an emptyTraceState.- Returns:
- a
Builderbased on an emptyTraceState.
-
toBuilder
public TraceState.Builder toBuilder()
Returns aBuilderbased on thisTraceState.- Returns:
- a
Builderbased on thisTraceState.
-
-