관리-도구
편집 파일: propagator.cpython-38.pyc
U �Mg� � @ s� d dl mZ d dlmZmZmZ d dlmZmZm Z m Z mZmZ d dl mZmZmZ d dlmZmZ d dlmZ d dlmZmZ d dlmZmZ d d lmZ er�d d lmZmZ G dd� de �Z d S )� )�trace)�Context�get_current� set_value)�CarrierT�Getter�Setter�TextMapPropagator�default_getter�default_setter)�NonRecordingSpan�SpanContext� TraceFlags)�SENTRY_BAGGAGE_KEY�SENTRY_TRACE_KEY)�SentrySpanProcessor)�BAGGAGE_HEADER_NAME�SENTRY_TRACE_HEADER_NAME)�Baggage�extract_sentrytrace_data)� TYPE_CHECKING)�Optional�Setc @ s8 e Zd ZdZdefdd�Zdefdd�Zedd� �Z dS ) �SentryPropagatorz[ Propagates tracing headers for Sentry's tracing system in a way OTel understands. Nc C s� |d krt � }|�|t�}|s"|S t|d �}|s6|S tt||�}|d |d }}tt|d�t|d�ttj �dd�}|�|t �} | r�t�| d �} n ti d�} | � � tt| |�}t|�}t�||�}|S )Nr �trace_idZparent_span_id� T)r �span_idZtrace_flagsZ is_remote)Zsentry_items)r �getr r r r r �intr ZSAMPLEDr r Zfrom_incoming_header�freezer r r Zset_span_in_context) �self�carrier�context�getterZsentry_traceZsentrytracer r Zspan_contextZbaggage_header�baggage�spanZmodified_context� r&