
    Zj	                     d    d dl Z d dlZd dlmZ  G d de j                  Z G d de          ZdS )    N)tracec                   f    e Zd Zej        defd            Zej        defd            ZdefdZ	dS )IdGeneratorreturnc                     dS )z[Get a new span ID.

        Returns:
            A 64-bit int for use as a span ID
        N selfs    a/var/www/FlaskApp/flask-venv/lib/python3.11/site-packages/opentelemetry/sdk/trace/id_generator.pygenerate_span_idzIdGenerator.generate_span_id             c                     dS )ax  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 <https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#traceidratiobased>`_.

        Returns:
            A 128-bit int for use as a trace ID
        Nr   r	   s    r   generate_trace_idzIdGenerator.generate_trace_id   r   r   c                     dS )aR  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 <https://www.w3.org/TR/trace-context-2/#considerations-for-trace-id-field-generation>`_.

        Returns:
            True if this generator produces random IDs, False otherwise.
        Fr   r	   s    r   is_trace_id_randomzIdGenerator.is_trace_id_random%   s	     ur   N)
__name__
__module____qualname__abcabstractmethodintr   r   boolr   r   r   r   r   r   
   s        #     	3    "D      r   r   c                   6    e Zd ZdZdefdZdefdZdefdZdS )RandomIdGeneratorzkThe default ID generator for TracerProvider which randomly generates all
    bits when generating IDs.
    r   c                     t          j        d          }|t          j        k    r$t          j        d          }|t          j        k    $|S )N@   )randomgetrandbitsr   INVALID_SPAN_ID)r
   span_ids     r   r   z"RandomIdGenerator.generate_span_id;   sE    $R((...(,,G ...r   c                     t          j        d          }|t          j        k    r$t          j        d          }|t          j        k    $|S )N   )r   r   r   INVALID_TRACE_ID)r
   trace_ids     r   r   z#RandomIdGenerator.generate_trace_idA   sE    %c**%000)#..H %000r   c                     dS )NTr   r	   s    r   r   z$RandomIdGenerator.is_trace_id_randomG   s    tr   N)	r   r   r   __doc__r   r   r   r   r   r   r   r   r   r   6   so         #    3    D      r   r   )r   r   opentelemetryr   ABCr   r   r   r   r   <module>r*      s    


       ) ) ) ) )#' ) ) )X         r   