
    fi9                        d dl mZmZ d dlmZ d dlmZmZ d dlm	Z	m
Z
 	 d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ n# e$ r  ed          w xY wd dlmZ erd dlmZmZmZmZ d ZddZ G d de          Z dS )    )IntegrationDidNotEnable)%register_external_propagation_context)loggerDsn)VERSIONEndpointType)trace)set_global_textmap)TracerProvider)BatchSpanProcessor)OTLPSpanExporter)SentryPropagatorz+opentelemetry-distro[otlp] is not installed)TYPE_CHECKING)OptionalDictAnyTuplec                     t          j                                                    } | j        t           j        k    s| j        t           j        k    rdS t          j        | j                  t          j        | j                  fS )zC
    Get the (trace_id, span_id) from opentelemetry if exists.
    N)	r
   get_current_spanget_span_contexttrace_idINVALID_TRACE_IDspan_idINVALID_SPAN_IDformat_trace_idformat_span_id)ctxs    l/var/www/html/Pagina-Ingenieria-Requisitos/venv/lib/python3.11/site-packages/sentry_sdk/integrations/otlp.pyotel_propagation_contextr       sg    
 
 
"
"
3
3
5
5C
|u---@U1U1Ut!#,//1Eck1R1RSS    Nc                 $   t          j                    }t          |t                    s6t	          j        d           t                      }t          j        |           d }d }| rvt          |                               dt                     }|
                    t          j                  }d|                                i}t	          j        d|            t          ||          }t          |          }|                    |           d S )Nz?[OTLP] No TracerProvider configured by user, creating a new onezsentry.python/zX-Sentry-Authz[OTLP] Sending traces to )endpointheaders)r
   get_tracer_provider
isinstancer   r   debugset_tracer_providerr   to_authr   get_api_urlr	   OTLP_TRACES	to_headerr   r   add_span_processor)dsntracer_providerr#   r$   authotlp_exporterspan_processors          r   setup_otlp_exporterr3   $   s    /11Oo~66 3VWWW(**!/222HG
 =3xx : : :;;##L$<=="DNN$4$45;;;<<<$hHHHM'66N&&~66666r!   c                   8    e Zd ZdZddZed             ZddZdS )	OTLPIntegrationotlpTc                 "    || _         || _        d S N)r3   setup_propagator)selfr3   r9   s      r   __init__zOTLPIntegration.__init__=   s    #6  0r!   c                  V    t          j        d           t          t                     d S )Nz.[OTLP] Setting up trace linking for all events)r   r'   r   r     r!   r   
setup_oncezOTLPIntegration.setup_onceB   s*     	EFFF-.FGGGGGr!   Nc                     | j         r<t          j        d           |r|                    d          nd }t          |           | j        r1t          j        d           t          t                                 d S d S )Nz[OTLP] Setting up OTLP exporterr.   z4[OTLP] Setting up propagator for distributed tracing)r3   r   r'   getr9   r   r   )r:   optionsr.   s      r   setup_once_with_optionsz'OTLPIntegration.setup_once_with_optionsH   s    # 	%L:;;;(/9'++e$$$TC$$$  	3LOPPP/1122222	3 	3r!   )TTr8   )__name__
__module____qualname__
identifierr;   staticmethodr>   rB   r=   r!   r   r5   r5   :   s_        J1 1 1 1
 H H \H

3 
3 
3 
3 
3 
3r!   r5   r8   )!sentry_sdk.integrationsr   r   sentry_sdk.scoper   sentry_sdk.utilsr   r   sentry_sdk.constsr   r	   opentelemetryr
   opentelemetry.propagater   opentelemetry.sdk.tracer   opentelemetry.sdk.trace.exportr   5opentelemetry.exporter.otlp.proto.http.trace_exporterr   0sentry_sdk.integrations.opentelemetry.propagatorr   ImportErrortypingr   r   r   r   r   r    r3   r5   r=   r!   r   <module>rT      s   = = = = = = = = B B B B B B ( ( ( ( ( ( ( ( 3 3 3 3 3 3 3 3	F######::::::666666AAAAAAVVVVVVQQQQQQQ F F F
,D
E
EEF !           2111111111111
T 
T 
T7 7 7 7,3 3 3 3 3k 3 3 3 3 3s   $A A