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 ArrayBasedTraceState
EMPTY
private static int
KEY_MAX_SIZE
private static int
MAX_ENTRIES
private static int
MAX_TENANT_ID_SIZE
private static int
MAX_VENDOR_ID_SIZE
(package private) int
numEntries
private java.util.List<java.lang.String>
reversedEntries
private static int
VALUE_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 TraceState
build()
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 TraceState
empty()
private static boolean
isKeyValid(java.lang.String key)
Checks the validity of a key.private static boolean
isNotDigit(char ch)
private static boolean
isNotLegalKeyCharacter(char c)
private static boolean
isNotLowercaseLetterOrDigit(char ch)
private static boolean
isValueValid(java.lang.String value)
TraceStateBuilder
put(java.lang.String key, java.lang.String value)
Allows key value pairs to be added to the TraceState.TraceStateBuilder
remove(java.lang.String key)
Removes theEntry
that has the givenkey
if 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:
put
in 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 theEntry
to be added.- Returns:
- this.
-
remove
public TraceStateBuilder remove(java.lang.String key)
Description copied from interface:TraceStateBuilder
Removes theEntry
that has the givenkey
if it is present.- Specified by:
remove
in interfaceTraceStateBuilder
- Parameters:
key
- the key for theEntry
to be removed.- Returns:
- this.
-
build
public TraceState build()
Description copied from interface:TraceStateBuilder
Builds a TraceState by adding the entries to the parent in front of the key-value pairs list and removing duplicate entries.- Specified by:
build
in 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)
-
-