Interface IdGenerator


@ThreadSafe public interface IdGenerator
Interface used by the SdkTracer to generate new SpanIds and TraceIds.
  • Method Summary

    Modifier and Type
    Method
    Description
    Generates a new valid SpanId.
    default boolean
    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.
    Generates a new valid TraceId.
    Returns a IdGenerator that generates purely random IDs, which is the default for OpenTelemetry.
  • Method Details

    • random

      static IdGenerator random()
      Returns a IdGenerator that generates purely random IDs, which is the default for OpenTelemetry.

      The underlying implementation uses ThreadLocalRandom for randomness but may change in the future.

    • generateSpanId

      String generateSpanId()
      Generates a new valid SpanId.
      Returns:
      a new valid SpanId.
    • generateTraceId

      String generateTraceId()
      Generates a new valid TraceId.
      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