Package io.opentelemetry.sdk.trace
Interface IdGenerator
@ThreadSafe
public interface IdGenerator
Interface used by the
SdkTracer to generate new SpanIds and TraceIds.-
Method Summary
Modifier and TypeMethodDescriptionGenerates a new validSpanId.default booleanDeclares whether TraceIds generated by this IdGenerator have their lower 56 bits uniformly distributed over the [0..2^56-1]interval, making them compatible with W3C Trace Context Level 2 recommendation @see Random TraceId flag.Generates a new validTraceId.static IdGeneratorrandom()Returns aIdGeneratorthat generates purely random IDs, which is the default for OpenTelemetry.
-
Method Details
-
random
Returns aIdGeneratorthat generates purely random IDs, which is the default for OpenTelemetry.The underlying implementation uses
ThreadLocalRandomfor randomness but may change in the future. -
generateSpanId
String generateSpanId()Generates a new validSpanId.- Returns:
- a new valid
SpanId.
-
generateTraceId
String generateTraceId()Generates a new validTraceId.- Returns:
- a new valid
TraceId.
-
generatesRandomTraceIds
default boolean generatesRandomTraceIds()Declares whether TraceIds generated by this IdGenerator have their lower 56 bits uniformly distributed over the [0..2^56-1]interval, making them compatible with W3C Trace Context Level 2 recommendation @see Random TraceId flag.- Returns:
- true if the generated TraceIds are random
- Since:
- 1.60.0
-