Package io.opentelemetry.api.trace
Class ArrayBasedTraceStateBuilder
- java.lang.Object
-
- io.opentelemetry.api.trace.ArrayBasedTraceStateBuilder
-
- All Implemented Interfaces:
TraceStateBuilder
final class ArrayBasedTraceStateBuilder extends java.lang.Object implements TraceStateBuilder
-
-
Field Summary
Fields Modifier and Type Field Description private static ArrayBasedTraceStateEMPTYprivate static intKEY_MAX_SIZEprivate static intMAX_ENTRIESprivate static intMAX_TENANT_ID_SIZEprivate static intMAX_VENDOR_ID_SIZE(package private) intnumEntriesprivate java.util.List<java.lang.String>reversedEntriesprivate static intVALUE_MAX_SIZE
-
Constructor Summary
Constructors Constructor Description ArrayBasedTraceStateBuilder()ArrayBasedTraceStateBuilder(ArrayBasedTraceState parent)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TraceStatebuild()Builds a TraceState by adding the entries to the parent in front of the key-value pairs list and removing duplicate entries.(package private) static TraceStateempty()private static booleanisKeyValid(java.lang.String key)Checks the validity of a key.private static booleanisNotDigit(char ch)private static booleanisNotLegalKeyCharacter(char c)private static booleanisNotLowercaseLetterOrDigit(char ch)private static booleanisValueValid(java.lang.String value)TraceStateBuilderput(java.lang.String key, java.lang.String value)Allows key value pairs to be added to the TraceState.TraceStateBuilderremove(java.lang.String key)Removes theEntrythat has the givenkeyif it is present.
-
-
-
Field Detail
-
MAX_VENDOR_ID_SIZE
private static final int MAX_VENDOR_ID_SIZE
- See Also:
- Constant Field Values
-
EMPTY
private static final ArrayBasedTraceState EMPTY
-
MAX_ENTRIES
private static final int MAX_ENTRIES
- See Also:
- Constant Field Values
-
KEY_MAX_SIZE
private static final int KEY_MAX_SIZE
- See Also:
- Constant Field Values
-
VALUE_MAX_SIZE
private static final int VALUE_MAX_SIZE
- See Also:
- Constant Field Values
-
MAX_TENANT_ID_SIZE
private static final int MAX_TENANT_ID_SIZE
- See Also:
- Constant Field Values
-
reversedEntries
private final java.util.List<java.lang.String> reversedEntries
-
numEntries
int numEntries
-
-
Constructor Detail
-
ArrayBasedTraceStateBuilder
ArrayBasedTraceStateBuilder()
-
ArrayBasedTraceStateBuilder
ArrayBasedTraceStateBuilder(ArrayBasedTraceState parent)
-
-
Method Detail
-
empty
static TraceState empty()
-
put
public TraceStateBuilder put(java.lang.String key, java.lang.String value)
Allows key value pairs to be added to the TraceState.- Specified by:
putin interfaceTraceStateBuilder- Parameters:
key- is an 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 /. For multi-tenant vendor scenarios, an at sign (@) can be used to prefix the vendor name. The tenant id (before the '@') is limited to 240 characters and the vendor id is limited to 13 characters. If in the multi-tenant vendor format, then the first character may additionally be numeric.value- the value for theEntryto be added.- Returns:
- this.
-
remove
public TraceStateBuilder remove(java.lang.String key)
Description copied from interface:TraceStateBuilderRemoves theEntrythat has the givenkeyif it is present.- Specified by:
removein interfaceTraceStateBuilder- Parameters:
key- the key for theEntryto be removed.- Returns:
- this.
-
build
public TraceState build()
Description copied from interface:TraceStateBuilderBuilds a TraceState by adding the entries to the parent in front of the key-value pairs list and removing duplicate entries.- Specified by:
buildin interfaceTraceStateBuilder- Returns:
- a TraceState with the new entries.
-
isKeyValid
private static boolean isKeyValid(@Nullable java.lang.String key)Checks the validity of a key.- Parameters:
key- is an 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 /. For multi-tenant vendor scenarios, an at sign (@) can be used to prefix the vendor name. The tenant id (before the '@') is limited to 240 characters and the vendor id is limited to 13 characters. If in the multi-tenant vendor format, then the first character may additionally be numeric.- Returns:
- boolean representing key validity
-
isNotLegalKeyCharacter
private static boolean isNotLegalKeyCharacter(char c)
-
isNotLowercaseLetterOrDigit
private static boolean isNotLowercaseLetterOrDigit(char ch)
-
isNotDigit
private static boolean isNotDigit(char ch)
-
isValueValid
private static boolean isValueValid(@Nullable java.lang.String value)
-
-