
    Yfi                     d   d dl mZ d dlmZ d dlmZ d dlmZmZ d dl	m
Z
 d dlmZmZmZ d dlmZmZ d dlmZ erd 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 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  d dl!m"Z" d dl	m#Z# d dl$m%Z% d dlm&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z, d dlm-Z- d dlm.Z.  ed      Z/nd Z ed      Z0d Z1 G d d       Z2d! Z3d" Z4d dlmZ er G d# d$e-e2      Z5n d%        Z5 G d& d'e6      Z7 G d( d) ee7            Z8 e8       Z9e0ju                  e9       d d*l;m<Z< y+),    )contextmanager)with_metaclass)INSTRUMENTER)Scope_ScopeManager)Client)NoOpSpanSpanTransaction)logger
ContextVar)TYPE_CHECKING)Any)Callable)ContextManager)Dict)	Generator)List)Optional)overload)Tuple)Type)TypeVar)Union)Unpack)
BaseClient)Integration)EventHint
BreadcrumbBreadcrumbHintExcInfoLogLevelStrSamplingContext)ClientConstructor)TransactionKwargsTc                     | S N )xs    N/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/sentry_sdk/hub.pyr   r   6   s        sentry_current_hubc                  \    t         j                  j                  } | sy| j                         S )NF)Hubcurrentclientshould_send_default_pii)r2   s    r,   _should_send_default_piir4   >   s(     [[F))++r-   c                       e Zd Zd Zd Zd Zy)
_InitGuardc                     || _         y r)   )_clientselfr2   s     r,   __init__z_InitGuard.__init__I   s	    r-   c                     | S r)   r*   r:   s    r,   	__enter__z_InitGuard.__enter__M   s    r-   c                 B    | j                   }||j                          y y r)   )r8   close)r:   exc_type	exc_valuetbcs        r,   __exit__z_InitGuard.__exit__Q   s    LL=GGI r-   N)__name__
__module____qualname__r;   r>   rE   r*   r-   r,   r6   r6   H   s    r-   r6   c                       y r)   r*   r*   r-   r,   _check_python_deprecationsrJ   X   s    
 	r-   c                      t        | i |}t        j                  j                  |       t	                t        |      }|S )zsInitializes the SDK and optionally integrations.

    This takes the same arguments as the client constructor.
    )r   r0   r1   bind_clientrJ   r6   )argskwargsr2   rvs       r,   _initrP   `   s:     T$V$FKKF# 	F	BIr-   c                       e Zd Zy)initN)rF   rG   rH   r*   r-   r,   rR   rR   v   s    r-   rR   c                      t         S r)   )rP   r*   r-   r,   <lambda>rT   ~   s    E r-   c                   ,    e Zd Zed        Zed        Zy)HubMetac                 |    t         j                  d      }|$t        t              }t         j	                  |       |S )z(Returns the current instance of the hub.N)_localgetr0   
GLOBAL_HUBset)clsrO   s     r,   r1   zHubMeta.current   s0     ZZ:ZBJJrN	r-   c                     t         S )z%Returns the main instance of the hub.)rZ   )r\   s    r,   mainzHubMeta.main   s
     r-   N)rF   rG   rH   propertyr1   r^   r*   r-   r,   rV   rV      s(       r-   rV   c                      e Zd ZdZdZdZerdZdZ	 	 d$dZ	d Z
d Zd Zd Zed        Zed	        Zd
 Zd Zd$dZd$dZd$dZd Zd$dZej2                  fdZdej2                  dfdZd%dZe	 d&d       Zed        Z	 	 d'dZd Ze	 d&d       Z ed        Z 	 	 d'dZ 	 d(dZ!d Z"d Z#d Z$	 	 d$dZ%d  Z&d! Z'd&d"Z(d&d#Z)y))r0   a  
    .. deprecated:: 2.0.0
        The Hub is deprecated. Its functionality will be merged into :py:class:`sentry_sdk.scope.Scope`.

    The hub wraps the concurrency management of the SDK.  Each thread has
    its own hub but the hub might transfer with the flow of execution if
    context vars are available.

    If the hub is used with a with statement it's temporarily activated.
    Nc                    d }t        |t              r[t        j                         }|jt        j                         j                         }t        j                         j                         }n%|}t        j                         j                  |       |(t        j                         }t        j                         }|t        j                         }||fg| _	        d | _
        g | _        g | _        g | _        || _        || _        y r)   )
isinstancer0   r   
get_clientget_isolation_scopeforkget_current_scopeget_global_scope
set_client_stack_last_event_id	_old_hubs_old_current_scopes_old_isolation_scopes_current_scope_scope)r:   client_or_hubscopecurrent_scoper2   s        r,   r;   zHub.__init__   s     mS)%%'F}11388: % 7 7 9 > > @"F""$//7=--/E!335M !335M'"#% %'"+r-   c                    | j                   j                  t        j                         t        j                  |        t        j                         }| j                  j                  |       t        j                  j                  | j                         t        j                         }| j                  j                  |       t        j                  j                  | j                         | S r)   )rk   appendr0   r1   rX   r[   r   rf   rl   rq   rn   rd   rm   _isolation_scopero   )r:   rr   isolation_scopes      r,   r>   zHub.__enter__   s    ckk*

4//1  ''6  !4!45335""))/:""4;;/r-   c                 F   | j                   j                         }t        j                  |       | j                  j                         }t
        j                  j                  |       | j                  j                         }t
        j                  j                  |       y r)   )	rk   poprX   r[   rl   rq   rn   rm   ru   )r:   rA   rB   rC   oldold_current_scopeold_isolation_scopes          r,   rE   zHub.__exit__   su     nn  "

3 4488:  !23"88<<>""#67r-   c                 @    | 5   |       cddd       S # 1 sw Y   yxY w)z
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.

        Runs a callback in the context of the hub.  Alternatively the
        with statement can be used on the hub directly.
        Nr*   r:   callbacks     r,   runzHub.run   s!      	:	 	 	s   c                 H    t        j                         j                  |      S )a  
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.
            Please use :py:meth:`sentry_sdk.client._Client.get_integration` instead.

        Returns the integration for this hub by name or class.  If there
        is no client bound or the client does not have that integration
        then `None` is returned.

        If the return value is not `None` the hub is guaranteed to have a
        client attached.
        )r   rc   get_integration)r:   name_or_classs     r,   r   zHub.get_integration   s      !11-@@r-   c                 P    t        j                         }|j                         sy|S )z
        .. deprecated:: 2.0.0
            This property is deprecated and will be removed in a future release.
            Please use :py:func:`sentry_sdk.api.get_client` instead.

        Returns the current client on the hub.
        N)r   rc   	is_activer9   s     r,   r2   z
Hub.client  s&     !!#!r-   c                 *    t        j                         S )z
        .. deprecated:: 2.0.0
            This property is deprecated and will be removed in a future release.
            Returns the current scope on the hub.
        )r   rd   r=   s    r,   rq   z	Hub.scope  s     ((**r-   c                 D    t        j                  d       | j                  S )a  
        Returns the last event ID.

        .. deprecated:: 1.40.5
            This function is deprecated and will be removed in a future release. The functions `capture_event`, `capture_message`, and `capture_exception` return the event ID directly.
        zDeprecated: last_event_id is deprecated. This will be removed in the future. The functions `capture_event`, `capture_message`, and `capture_exception` return the event ID directly.)r   warningrj   r=   s    r,   last_event_idzHub.last_event_id'  s$     	 C	
 """r-   c                 J    t        j                         j                  |       y)z
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.
            Please use :py:meth:`sentry_sdk.Scope.set_client` instead.

        Binds a new client to the hub.
        N)r   rg   rh   )r:   news     r,   rL   zHub.bind_client4  s     	 ++C0r-   c                      t        j                         j                  ||fd|i|}|j                  d      dk(  }|	|s|| _        |S )a  
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.
            Please use :py:meth:`sentry_sdk.Scope.capture_event` instead.

        Captures an event.

        Alias of :py:meth:`sentry_sdk.Scope.capture_event`.

        :param event: A ready-made event that can be directly sent to Sentry.

        :param hint: Contains metadata about the event that can be read from `before_send`, such as the original exception object or a HTTP request object.

        :param scope: An optional :py:class:`sentry_sdk.Scope` to apply to events.
            The `scope` and `scope_kwargs` parameters are mutually exclusive.

        :param scope_kwargs: Optional data to apply to event.
            For supported `**scope_kwargs` see :py:meth:`sentry_sdk.Scope.update_from_kwargs`.
            The `scope` and `scope_kwargs` parameters are mutually exclusive.
        rq   typetransaction)r   rf   capture_eventrY   rj   )r:   eventhintrq   scope_kwargsr   is_transactions          r,   r   zHub.capture_eventA  s`    , @//1??4
$
(4
 6*m;$^"/Dr-   c                 h     t        j                         j                  |f||d|}||| _        |S )a  
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.
            Please use :py:meth:`sentry_sdk.Scope.capture_message` instead.

        Captures a message.

        Alias of :py:meth:`sentry_sdk.Scope.capture_message`.

        :param message: The string to send as the message to Sentry.

        :param level: If no level is provided, the default level is `info`.

        :param scope: An optional :py:class:`sentry_sdk.Scope` to apply to events.
            The `scope` and `scope_kwargs` parameters are mutually exclusive.

        :param scope_kwargs: Optional data to apply to event.
            For supported `**scope_kwargs` see :py:meth:`sentry_sdk.Scope.update_from_kwargs`.
            The `scope` and `scope_kwargs` parameters are mutually exclusive.

        :returns: An `event_id` if the SDK decided to send the event (see :py:meth:`sentry_sdk.client._Client.capture_event`).
        )levelrq   )r   rf   capture_messagerj   )r:   messager   rq   r   r   s         r,   r   zHub.capture_messagea  sK    0 B//1AA
 
1=
 $"/Dr-   c                 f     t        j                         j                  |fd|i|}||| _        |S )a  
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.
            Please use :py:meth:`sentry_sdk.Scope.capture_exception` instead.

        Captures an exception.

        Alias of :py:meth:`sentry_sdk.Scope.capture_exception`.

        :param error: An exception to capture. If `None`, `sys.exc_info()` will be used.

        :param scope: An optional :py:class:`sentry_sdk.Scope` to apply to events.
            The `scope` and `scope_kwargs` parameters are mutually exclusive.

        :param scope_kwargs: Optional data to apply to event.
            For supported `**scope_kwargs` see :py:meth:`sentry_sdk.Scope.update_from_kwargs`.
            The `scope` and `scope_kwargs` parameters are mutually exclusive.

        :returns: An `event_id` if the SDK decided to send the event (see :py:meth:`sentry_sdk.client._Client.capture_event`).
        rq   )r   rf   capture_exceptionrj   )r:   errorrq   r   r   s        r,   r   zHub.capture_exception  sI    , D//1CC

".
 $"/Dr-   c                 2    t        j                  d|       y)a  
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.
            Please use :py:meth:`sentry_sdk.client._Client._capture_internal_exception` instead.

        Capture an exception that is likely caused by a bug in the SDK
        itself.

        Duplicated in :py:meth:`sentry_sdk.client._Client._capture_internal_exception`.

        These exceptions do not end up in Sentry and are just logged instead.
        zInternal error in sentry_sdk)exc_infoN)r   r   )r:   r   s     r,   _capture_internal_exceptionzHub._capture_internal_exception  s      	3hGr-   c                 P     t        j                         j                  ||fi | y)a  
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.
            Please use :py:meth:`sentry_sdk.Scope.add_breadcrumb` instead.

        Adds a breadcrumb.

        :param crumb: Dictionary with the data as the sentry v7/v8 protocol expects.

        :param hint: An optional value that can be used by `before_breadcrumb`
            to customize the breadcrumbs that are emitted.
        N)r   rd   add_breadcrumb)r:   crumbr   rN   s       r,   r   zHub.add_breadcrumb  s$     	3!!#225$I&Ir-   c                 R    t        j                         } |j                  dd|i|S )aJ  
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.
            Please use :py:meth:`sentry_sdk.Scope.start_span` instead.

        Start a span whose parent is the currently active span or transaction, if any.

        The return value is a :py:class:`sentry_sdk.tracing.Span` instance,
        typically used as a context manager to start and stop timing in a `with`
        block.

        Only spans contained in a transaction are sent to Sentry. Most
        integrations start a transaction at the appropriate time, for example
        for every incoming HTTP request. Use
        :py:meth:`sentry_sdk.start_transaction` to start a new transaction when
        one is not already in progress.

        For supported `**kwargs` see :py:class:`sentry_sdk.tracing.Span`.
        instrumenterr*   )r   rf   
start_span)r:   r   rN   rq   s       r,   r   zHub.start_span  s-    * '')uD\DVDDr-   c                 ^    t        j                         }||d<    |j                  |||fi |S )a  
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.
            Please use :py:meth:`sentry_sdk.Scope.start_transaction` instead.

        Start and return a transaction.

        Start an existing transaction if given, otherwise create and start a new
        transaction with kwargs.

        This is the entry point to manual tracing instrumentation.

        A tree structure can be built by adding child spans to the transaction,
        and child spans to other spans. To start a new child span within the
        transaction or any span, call the respective `.start_child()` method.

        Every child span must be finished before the transaction is finished,
        otherwise the unfinished spans are discarded.

        When used as context managers, spans and transactions are automatically
        finished at the end of the `with` block. If not using context managers,
        call the `.finish()` method.

        When the transaction is finished, it will be sent to Sentry with all its
        finished child spans.

        For supported `**kwargs` see :py:class:`sentry_sdk.tracing.Transaction`.
        hub)r   rf   start_transaction)r:   r   r   custom_sampling_contextrN   rq   s         r,   r   zHub.start_transaction  sC    H '')
 u&u&&'>
BH
 	
r-   c                 P    t        j                         j                  ||||      S )a   
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.
            Please use :py:meth:`sentry_sdk.Scope.continue_trace` instead.

        Sets the propagation context from environment or headers and returns a transaction.
        )environ_or_headersopnamesource)r   rd   continue_trace)r:   r   r   r   r   s        r,   r   zHub.continue_trace
  s.     ((*991btF : 
 	
r-   c                      y r)   r*   r}   s     r,   
push_scopezHub.push_scope      
 	r-   c                      y r)   r*   r}   s     r,   r   zHub.push_scope  r   r-   c                 x    |"| j                         5 } ||       ddd       yt        |       S # 1 sw Y   yxY w)a  
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.

        Pushes a new layer on the scope stack.

        :param callback: If provided, this method pushes a scope, calls
            `callback`, and pops the scope again.

        :returns: If no `callback` is provided, a context manager that should
            be used to pop the scope again.
        N)r   r   )r:   r~   r   rq   s       r,   r   zHub.push_scope%  s>    $ "  e T""	 s   	09c                 `    | j                   j                         }| j                   sJ d       |S )z
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.

        Pops a scope layer from the stack.

        Try to use the context manager :py:meth:`push_scope` instead.
        z"stack must have at least one layer)ri   rx   )r:   rO   s     r,   pop_scope_unsafezHub.pop_scope_unsafe>  s+     [[__{{@@@{	r-   c                      y r)   r*   r}   s     r,   configure_scopezHub.configure_scopeL  r   r-   c                      y r)   r*   r}   s     r,   r   zHub.configure_scopeS  r   r-   c                     t        j                         |r j                          |	 |       yt        fd       } |       S )aK  
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.

        Reconfigures the scope.

        :param callback: If provided, call the callback with the current scope.

        :returns: If no callback is provided, returns a context manager that returns the scope.
        Nc               3      K     y wr)   r*   rq   s   r,   innerz"Hub.configure_scope.<locals>.inneru  s      Ks   	)r   rd   generate_propagation_contextr   )r:   r~   r   r   rq   s       @r,   r   zHub.configure_scopeZ  sO      ))+.E..0UO		 
	 wr-   c                 L    t        j                         j                  |       y)z
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.
            Please use :py:meth:`sentry_sdk.Scope.start_session` instead.

        Starts a new session.
        )session_modeN)r   rd   start_session)r:   r   s     r,   r   zHub.start_session|  s#     	!!#11% 	2 	
r-   c                 H    t        j                         j                          y)z
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.
            Please use :py:meth:`sentry_sdk.Scope.end_session` instead.

        Ends the current session if there is one.
        N)r   rd   end_sessionr=   s    r,   r   zHub.end_session  s     	!!#//1r-   c                 H    t        j                         j                          y)a  
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.
            Please use :py:meth:`sentry_sdk.Scope.stop_auto_session_tracking` instead.

        Stops automatic session tracking.

        This temporarily session tracking for the current scope when called.
        To resume session tracking call `resume_auto_session_tracking`.
        N)r   rd   stop_auto_session_trackingr=   s    r,   r   zHub.stop_auto_session_tracking  s     	!!#>>@r-   c                 H    t        j                         j                          y)a}  
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.
            Please use :py:meth:`sentry_sdk.Scope.resume_auto_session_tracking` instead.

        Resumes automatic session tracking for the current scope if
        disabled earlier.  This requires that generally automatic session
        tracking is enabled.
        N)r   rd   resume_auto_session_trackingr=   s    r,   r   z Hub.resume_auto_session_tracking  s     	!!#@@Br-   c                 L    t        j                         j                  ||      S )a  
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.
            Please use :py:meth:`sentry_sdk.client._Client.flush` instead.

        Alias for :py:meth:`sentry_sdk.client._Client.flush`
        )timeoutr~   )r   rc   flush)r:   r   r~   s      r,   r   z	Hub.flush  s#     !''('KKr-   c                     t        j                         }|j                         }|$t        j                         }|j                         }|S )a  
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.
            Please use :py:meth:`sentry_sdk.Scope.get_traceparent` instead.

        Returns the traceparent either from the active span or from the scope.
        )r   rf   get_traceparentrd   )r:   rr   traceparentrv   s       r,   r   zHub.get_traceparent  sH     //1#335#779O)99;Kr-   c                     t        j                         }|j                         }|$t        j                         }|j                         }||j	                         S y)a  
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.
            Please use :py:meth:`sentry_sdk.Scope.get_baggage` instead.

        Returns Baggage either from the active span or from the scope.
        N)r   rf   get_baggagerd   	serialize)r:   rr   baggagerv   s       r,   r   zHub.get_baggage  sY     //1++-?#779O%113G$$&&r-   c                 J    t        j                         j                  |      S )a  
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.
            Please use :py:meth:`sentry_sdk.Scope.iter_trace_propagation_headers` instead.

        Return HTTP headers which allow propagation of trace data. Data taken
        from the span representing the request, if available, or the current
        span on the scope if not.
        span)r   rf   iter_trace_propagation_headersr:   r   s     r,   r   z"Hub.iter_trace_propagation_headers  s)     &&(GG H 
 	
r-   c                 x    |t        j                  d       t        j                         j	                  |      S )aE  
        .. deprecated:: 2.0.0
            This function is deprecated and will be removed in a future release.
            Please use :py:meth:`sentry_sdk.Scope.trace_propagation_meta` instead.

        Return meta tags which should be injected into HTML templates
        to allow propagation of trace information.
        zaThe parameter `span` in trace_propagation_meta() is deprecated and will be removed in the future.r   )r   r   r   rf   trace_propagation_metar   s     r,   r   zHub.trace_propagation_meta  s@     NNs &&(?? @ 
 	
r-   )NN)NNNr)   )NT)application)*rF   rG   rH   __doc__ri   ro   r   r1   r^   r;   r>   rE   r   r   r_   r2   rq   r   rL   r   r   r   r   r   r   SENTRYr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r*   r-   r,   r0   r0      st   	 FF  #J8 A$    + +#1@B>H$J  '3&9&9 E4 !(( $	-
^
     #2      F )
	2AC L$*

r-   r0   r   N)=
contextlibr   sentry_sdk._compatr   sentry_sdk.constsr   sentry_sdk.scoper   r   sentry_sdk.clientr   sentry_sdk.tracingr	   r
   r   sentry_sdk.utilsr   r   sentry_sdk._typesr   typingr   r   r   r   r   r   r   r   r   r   r   r   typing_extensionsr   r   sentry_sdk.integrationsr   r   r   r    r!   r"   r#   r$   r%   r&   r'   rX   r4   r6   rJ   rP   rR   r   rV   r0   rZ   r[   
sentry_sdkrq   r*   r-   r,   <module>r      s    % - * 1 $ 
 ,% (,3   44A
 
(	),  	
 , *  Dd $t	
.
! t	
n U
 

:  r-   