mf 8ddlZddlZddlZddlmZddlmZddlZddlmZm Z m Z ddl m Z m Z mZmZmZmZmZmZmZddlmZddlmZddlmZmZmZdd lmZdd l mZdd l m!Z!dd l"m#Z#dd l$m%Z%e%r2ddl&m'Z'ddl&m(Z(ddl&m)Z)ddl&m*Z*ddl&m+Z+ddl,m-Z-ddl$m.Z.m/Z/ddl m0Z0edZ1dZ2Gdde3Z4dd l$m%Z%e%r(Gddee)e5e'fZ6Gddee4Z7dSdZ6dZ7dS) N)datetime)islice) string_types text_type iteritems) capture_internal_exceptionscurrent_stacktracedisable_capture_eventformat_timestamp get_type_nameget_default_releaseget_default_environment handle_in_applogger) serialize)make_transport)DEFAULT_OPTIONSSDK_INFOClientConstructor)setup_integrations) ContextVar)SessionFlusher)Envelope)MYPY)Any)Callable)Dict)List)Optional)Scope)EventHint)Sessionclient_init_debugc|rCt|dtttfs|d|d}|dd}nd}t t }t |i|}||d||d<t|D] \}}||vrtd||||<!|d"tj d|d<|dt|d<|dt|d|d<|d+ttd rtj|d<|S) NrdsnzUnknown option SENTRY_DSNrelease environment server_name gethostname) isinstancerbytesstrdictrgetr TypeErrorosenvironr rhasattrsocketr,)argskwargsr'rvoptionskeyvalues H/opt/imunify360/venv/lib64/python3.11/site-packages/sentry_sdk/client.py _get_optionsr>-sZ DGi%<==a1gABBx o  BD#F##G 7;;u--5(( U b==)33899 93 %yJNN<005  )}+--9  - 3ByMBB= - WV]%C%C ".00= IceZdZdZdZdZdZdZedZ dZ dZ dd Z d Z dd Zd Z ddZ ddZdZdZd S)_ClientzThe client is internally responsible for capturing the events and forwarding them to sentry through the configured transport. It takes the client options as keyword arguments and optionally the DSN as first argument. cPt|i||_|dSN) get_optionsr: _init_impl)selfr7r8s r=__init__z_Client.__init__Us,"D3F33  r?cd|jiSNr:r:rFs r= __getstate__z_Client.__getstate__Zs4<((r?cH|d|_|dSrI)r:rE)rFstates r= __setstate__z_Client.__setstate__^s$Y'  r?c6td}fd} tjdt j_t |_d}jd|vr"td |tjdjd jd  _ t|dS#t|wxYw) NFcj}|r|sdSt|} t}t|dD]}|||jsdS||U)NTd) transportiterrr add_sessionitemscapture_envelope)sessionsrS sessions_iterenvelopesessionrFs r=_send_sessionsz*_Client._init_impl.._send_sessionsgsI H  NNM 5#::%mS9922G((1111~E**8444  5r?debug) flush_func)alwaysneversmallmediumrequest_bodiesz3Invalid value for request_bodies. Must be one of {} integrationsdefault_integrationsauto_enabling_integrations) with_defaultswith_auto_enabling_integrations) _client_init_debugr1setr:rrSrsession_flusher ValueErrorformatrrd)rF old_debugr\rcs` r=rEz_Client._init_implcs%&**511  5 5 5 5 5 .  " "4<#8 9 9 9+DL99DN#1^#L#L#LD CN|,-^CC IPP& !3 ^,"l+AB04 01!!!D   " "9 - - - - -  " "9 - - - -s B>C<<Dc|jdS)z%Returns the configured DSN as string.r'rJrKs r=r'z _Client.dsns|E""r?c|dtj|d<||||}|dS|}|jdrVd|vrRd|vrNd|vrJt 5dt |jddd d gi|d<dddn #1swxYwYd D]S}||<|j|/t|j|||<T|d Btt}t|j |d <||d <|dd|d<t||jd|jd}|/t||jdd}|jd}|h|ddkrOd}t 5|||pi}dddn #1swxYwY|t!jd||}|S)N timestampattach_stacktrace exception stacktracethreadsvalues with_localsFT)rtcrashedcurrent)r)r*r+distsdkrdplatformpythonin_app_excludein_app_include _experimentssmart_transaction_trimming)r before_sendtype transactionzbefore send dropped event (%s))r1rutcnowapply_to_eventr:rr rstripr0rsortedrdkeysrrrinfo) rFeventhintscopeevent_r;sdk_infor new_events r=_prepare_eventz_Client._prepare_events 99[ ! ! )!)!2!2E+   ))%66F~tE L, - 5((E))&&,..  *< $ ] ;++(-'+  $i                C B BCyy~~%$,s*;*G&t|C'899??AAc 99U   #H~~H'-d.?.D.D.F.F'G'GH^ $#E%L 99Z ( (E*  4< 014<@P3Q    +/<+G+K+K0,,El=1  "uyy'8'8M'I'II,.. ; ;'Ktzr::  ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;  hqk622 44 ur?Nc|ddkrdS| |jsdS|jddkr$tj|jdkrdS|||rdSdS)NrrTF sample_rateg?)r1_should_capturer:randomr)rFrrrs r=rz_Client._should_captures 99V   - -4  U%: 5 L '# - - 4< #>>>5  ! !% . . 5tr?cd}d}d}|dpid}|r9d}|D]4}|d}|r|ddurd}n5|d} |j]|dpid } t| piD]!\} } | d kr| }n"||rd nd| ||j|p|z dS) NFrsrvT mechanismhandleduserrequestheadersz user-agentrx)statusr user_agenterrors)r1rrlowerupdater) rFr[rrxerroredr exceptionserrorrrrkvs r=_update_session_from_eventz"_Client._update_session_from_eventsT ii ,,277AA  G#  !IIk22 y!9!9U!B!B"GEyy     %yy++1r66yAAG#GMr22  A7799 ,,!"JE-  '199T!>W%78      r?cvtjdrdS|jdS|i}|d}t|pd}|t jjx|d<}||||sdS||||}|dS|r|j nd}|r| |||d}|ddk}|s|rt|dttjd } |r| |n| ||pdD])} | | *|j| n|j||S) aCaptures an 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. :returns: An event ID. May be `None` if there is no DSN set or of if the SDK decided to discard the event for other reasons. In such situations setting `debug=True` on `init()` may help. FNevent_id attachmentsrr)rsent_at)r)r r1rSr0uuiduuid4hexrr_sessionrrr rradd_transaction add_eventadd_itemto_envelope_itemrW capture_event) rFrrrr event_optr[ris_transactionrZ attachments r=rz_Client.capture_event,s ! $U + + 4 > !4 <D99Z((DJB  +/:<<+; ;E* ##E477 4''tU;;  4%*3%..t  <  + +GU ; ; ;hh}-- "v..-?  4[ 4 )* 5/0A0ABBH .((3333""9---)/R A A !!*"="="?"?@@@@ N + +H 5 5 5 5 N ( ( 3 3 3r?ct|jstjddS|j|dS)Nz3Discarded session update because of missing release)r)rrrkrU)rFr[s r=capture_sessionz_Client.capture_sessionnsB 6 KM N N N N N  , ,W 5 5 5 5 5r?c|jR||||j|jd|_dSdS)z Close the client and shut down the transport. Arguments have the same semantics as :py:meth:`Client.flush`. Ntimeoutcallback)rSflushrkkillrFrrs r=closez _Client.closews^ > % JJwJ : : :  % % ' ' ' N   ! ! !!DNNN & %r?c|jF| |jd}|j|j||dSdS)a# Wait for the current events to be sent. :param timeout: Wait for at most `timeout` seconds. If no `timeout` is provided, the `shutdown_timeout` option value is used. :param callback: Is invoked with the number of pending events and the configured timeout. Nshutdown_timeoutr)rSr:rkrrs r=rz _Client.flushs\ > %,'9:  & & ( ( ( N 8 D D D D D & %r?c|SrCrrKs r= __enter__z_Client.__enter__s r?c.|dSrC)r)rFexc_type exc_valuetbs r=__exit__z_Client.__exit__s r?rC)NN)__name__r __qualname____doc__rGrLrOrEpropertyr'rrrrrrrrrrrr?r=rArANsK  ))) '.'.'.R##X# FFFP2 2" " " N @@@@D666""""$EEEE&r?rAceZdZdS)rDNrrrrr?r=rDrD r?rDceZdZdS)ClientNrrr?r=rrrr?rctSrC)r>rr?r=rs<r?ctSrC)rArr?r=rrsgr?)8r3rrr itertoolsrr6sentry_sdk._compatrrrsentry_sdk.utilsrr r r r r rrrsentry_sdk.serializerrsentry_sdk.transportrsentry_sdk.constsrrrsentry_sdk.integrationsrrsentry_sdk.sessionsrsentry_sdk.envelopersentry_sdk._typesrtypingrrrrrsentry_sdk.scoper r!r"r#rir>objectrAr/rDrrr?r=rs  AAAAAAAAAA                      ,+++++//////JJJJJJJJJJ666666''''''......(((((("""""" ,&&&&&&--------++++++ Z 344BRRRRRfRRRj #"""""!     'c3h        "G     (''**Koo FFFr?