# opentelemetry.sdk.trace.id_generator

class opentelemetry.sdk.trace.id_generator.IdGenerator

  Bases: `ABC`

  abstractmethod generate_span_id()

    Get a new span ID.

    Return type:

      `int`

    Returns:

      A 64-bit int for use as a span ID

  abstractmethod generate_trace_id()

    Get a new trace ID.

    Implementations should at least make the 56 least significant bits uniformly random. Samplers like the `TraceIdRatioBased` sampler rely on this randomness to make sampling decisions.

    If the implementation does randomly generate the 56 least significant bits, it should also implement `is_trace_id_random` to return True.

    See the specification on TraceIdRatioBased.

    Return type:

      `int`

    Returns:

      A 128-bit int for use as a trace ID

  is_trace_id_random()

    Indicates whether generated trace IDs are random.

    When True, the `trace-id` field will have the `random-trace-id` flag set in the W3C traceparent header. Per the W3C Trace Context specification, this indicates that at least the 7 rightmost bytes (56 bits) of the trace ID were generated randomly with uniform distribution.

    See the W3C Trace Context specification.

    Return type:

      `bool`

    Returns:

      True if this generator produces random IDs, False otherwise.

class opentelemetry.sdk.trace.id_generator.RandomIdGenerator

  Bases: `IdGenerator`

  The default ID generator for TracerProvider which randomly generates all bits when generating IDs.

  generate_span_id()

    Get a new span ID.

    Return type:

      `int`

    Returns:

      A 64-bit int for use as a span ID

  generate_trace_id()

    Get a new trace ID.

    Implementations should at least make the 56 least significant bits uniformly random. Samplers like the `TraceIdRatioBased` sampler rely on this randomness to make sampling decisions.

    If the implementation does randomly generate the 56 least significant bits, it should also implement `is_trace_id_random` to return True.

    See the specification on TraceIdRatioBased.

    Return type:

      `int`

    Returns:

      A 128-bit int for use as a trace ID

  is_trace_id_random()

    Indicates whether generated trace IDs are random.

    When True, the `trace-id` field will have the `random-trace-id` flag set in the W3C traceparent header. Per the W3C Trace Context specification, this indicates that at least the 7 rightmost bytes (56 bits) of the trace ID were generated randomly with uniform distribution.

    See the W3C Trace Context specification.

    Return type:

      `bool`

    Returns:

      True if this generator produces random IDs, False otherwise.