Viewing File: /opt/imunify360/venv/lib/python3.11/site-packages/sentry_sdk/__pycache__/tracing.cpython-311.pyc



]jdddlZddlZddlZddlZddlZddlZddlmZmZddlm	Z	ddl
Z
ddlmZm
Z
mZddlmZddlmZerddlmZnddlmZer.ddlZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZejdZGddeZ Gdde!Z"Gdde!Z#Gdde#Z$dZ%dZ&dZ'ej(dZ)dZ*dS)N)datetime	timedelta)Real)capture_internal_exceptionslogger	to_string)PY2)MYPY)Mapping)	Generator)Optional)Any)Dict)List)Tuple)SamplingContextz5^[ 	]*([0-9a-f]{32})?-?([0-9a-f]{16})?-?([01])?[ 	]*$c*eZdZ	ddZdZdZdZdS)EnvironHeadersHTTP_c"||_||_dSN)environprefix)selfrrs   I/opt/imunify360/venv/lib64/python3.11/site-packages/sentry_sdk/tracing.py__init__zEnvironHeaders.__init__0scx|j|j|ddzSN-_)rrreplaceupper)rkeys  r__getitem__zEnvironHeaders.__getitem__9s0|DK#++c3*?*?*E*E*G*GGHHrcNtdt|DS)Nc3K|]}dVdS)N).0r!s  r	<genexpr>z)EnvironHeaders.__len__.<locals>.<genexpr>?s"))1))))))r)sumiterrs r__len__zEnvironHeaders.__len__=s%))d4jj))))))rc#K|jD]y}t|ts|dd}||js[|t|jdVzdSr)r
isinstancestrr"r#
startswithrlen)rks  r__iter__zEnvironHeaders.__iter__As	(	(Aa%%
		#s##))++A<<,,
C$$&&'''''	(	(rN)r)__name__
__module____qualname__rr%r/r6r)rrrr/s]III***
(
(
(
(
(rrc"eZdZdZdZdZdZdS)
_SpanRecorderz5Limits the number of spans recorded in a transaction.maxlenspansc(|dz
|_g|_dS)Nr(r<rr=s  rrz_SpanRecorder.__init__Ssqj


rct|j|jkr	d|_dS|j|dSr)r4r>r=_span_recorderappend)rspans  raddz_SpanRecorder.add]sAtz??T[(("&DJd#####rN)r7r8r9__doc__	__slots__rrEr)rrr;r;Ns=??#I$$$$$rr;ceZdZdZdZ										ddZdZdZdZd	Z	d
Z
dZedZ
ed
ZdZedZdZdZdZdZdZdZddZdZdZdS)Span)trace_idspan_idparent_span_idsame_process_as_parentsampledopdescriptionstart_timestamp_start_timestamp_monotonicstatus	timestamp_tags_datarBhub_context_manager_state_containing_transactionc|d|vrttSt|S)z_
        Backwards-compatible implementation of Span and Transaction
        creation.
        transaction)object__new__Transaction)clskwargss  rr]zSpan.__new__|s3F"">>+...~~c"""rNTc|ptjj|_|ptjjdd|_||_||_||_||_||_	|	|_
||_i|_i|_
tj|_	t#j|_n#t($rYnwxYwd|_d|_d|_dS)N)uuiduuid4hexrJrKrLrMrNrOrPrSrWrUrVrutcnowrQtimeperf_counterrRAttributeErrorrTrBrY)rrJrKrLrMrNrOrPrWrSr[s           rrz
Span.__init__s!4DJLL$4
7$*,,"2233"7,&<#&

'00	
/3.?.A.AD++			D	"'+$$$sB88
CCcp|jt||_|j|dSr)rBr;rEr@s  rinit_span_recorderzSpan.init_span_recorders8&"/"7"7D%%%%%rcd|jjd|jd|jd|jd|jd|jd|jdS)	N<z(op=z, description:, trace_id=
, span_id=, parent_span_id=
, sampled=)>)	__class__r7rOrPrJrKrLrNr.s r__repr__z
Span.__repr__sZ
N###GGGMMMLLLLLL
	
rc|jptjj}|jd\}}|j}||_|||f|_|S)N)rW
sentry_sdkHubcurrent_stackrDrX)rrWr!scopeold_spans     r	__enter__zSpan.__enter__sDh0*.0:b>5:
'*E8&<#rc||d|j\}}}|`||||_dS)Ninternal_error)
set_statusrXfinishrD)rtyvaluetbrWr{r|s       r__exit__z
Span.__exit__sMOO,---#:UH'C


rc|d|jtd|jd|jd|}t|tr||_n|j|_|jx|_}|r|	||S)a
        Start a sub-span from the current span or transaction.

        Takes the same arguments as the initializer of :py:class:`Span`. The
        trace id, sampling decision, transaction pointer, and span recorder are
        inherited from the current span/transaction.
        rNN)rJrKrLr))

setdefaultrNrIrJrKr1r^rYrBrE)rr`rvrecorders    rstart_childzSpan.start_childs	)T\222

]D

QW

dK((	F)-B&&)-)EB&'+'::H	LL	rcDtjd|jdi|S)z$Deprecated: use start_child instead.z:Deprecated: use Span.start_child instead of Span.new_span.r))rwarningr)rr`s  rnew_spanz
Span.new_spans.	STTTt))&)))rcz|turtjdtjt|fi|S)aJ
        Create a Transaction with the given params, then add in data pulled from
        the 'sentry-trace' header in the environ (if any) before returning the
        Transaction.

        If the 'sentry-trace' header is malformed or missing, just create and
        return a Transaction instance with the given params.
        zXDeprecated: use Transaction.continue_from_environ instead of Span.continue_from_environ.)rIrrr^continue_from_headersr)r_rr`s   rcontinue_from_environzSpan.continue_from_environsI$;;N9


01H1HSSFSSSrc|turtjdtj|dfi|}|tdi|}d|_|S)a3
        Create a Transaction with the given params, then add in data pulled from
        the 'sentry-trace' header (if any) before returning the Transaction.

        If the 'sentry-trace' header is malformed or missing, just create and
        return a Transaction instance with the given params.
        zXDeprecated: use Transaction.continue_from_headers instead of Span.continue_from_headers.sentry-traceNFr))rIrrr^from_traceparentgetrM)r_headersr`r[s    rrzSpan.continue_from_headerss$;;N9


"2KK''

+1

%////K-2*rc#:Kd|fVdS)Nr)to_traceparentr.s riter_headerszSpan.iter_headers*s)d1133333333rc|turtjd|sdS|dr|dr
|dd}t
t|}|dS|\}}}|#d	t|d}|#d		t|d}|r|d
k}nd}td|||d|S)
a-
        Create a Transaction with the given params, then add in data pulled from
        the given 'sentry-trace' header value before returning the Transaction.

        If the header value is malformed or missing, just create and return a
        Transaction instance with the given params.
        zNDeprecated: use Transaction.from_traceparent instead of Span.from_traceparent.Nz00-z-00z{:032x}rbz{:016x}0)rJrLparent_sampledr))rIrrr3endswith_traceparent_header_format_rematchr2groupsformatintr^)r_traceparentr`rrJrLsampled_strrs        rrzSpan.from_traceparent.s5$;;N4



	4!!%((	,[-A-A%-H-H	,%ad+K-33C4D4DEE=405-.+ ''Hb(9(9::H%&--c.".E.EFFN	"(C/NN!N
))

	

	
rcZd}|jdurd}|jdurd}|jd|jd|S)NT1Frr )rNrJrK)rrNs  rrzSpan.to_traceparent_sF<4G<5  G!]]]DLLL''BBrc||j|<dSr)rUrr$rs   rset_tagzSpan.set_tagh
3rc||j|<dSr)rVrs   rset_dataz
Span.set_datalrrc||_dSrrS)rrs  rrzSpan.set_statusps
rcV|dt||dkr|ddSd|cxkrdkrnn|dkr|ddS|dkr|ddS|d	kr|d
dS|dkr|ddS|d
kr|ddS|dkr|ddS|ddSd|cxkrdkrqnnn|dkr|ddS|dkr|ddS|dkr|ddS|ddS|ddS)Nzhttp.status_codeiokiipermission_deniedi	not_foundiresource_exhaustedifailed_preconditioniunauthenticatedialready_existsinvalid_argumentiXideadline_exceededi
unimplementediunavailabler
unknown_error)rr2r)rhttp_statuss  rset_http_statuszSpan.set_http_statusts'[)9)9:::OOD!!!!!
K
%
%
%
%#
%
%
%
%
%c!! 344444##,,,,,## 455555## 566666## 122222## 011111 233333
K
%
%
%
%#
%
%
%
%
%c!! 344444##00000##
..... 011111OOO,,,,,rc|jdkS)Nrrr.s r
is_successzSpan.is_successs{d""rc0|jdS|p|jptjj}	tj|jz
}|jt|z|_n(#t$rtj|_YnwxYwt||dS)N)seconds)rTrWrwrxryrgrhrRrQrrirrf#_maybe_create_breadcrumbs_from_span)rrWduration_secondss   rrzSpan.finishs>%47TX7!7	/#022T5TT!1IFV4W4W4WWDNN	/	/	/%_..DNNN	/	,C666ts8A"BBc	|j|j|j|j|j|j|j|jd}|jr|j|j	d<|j	}|r||d<|j
}|r||d<|S)N)rJrKrLrMrOrPrQrTrStagsdata)rJrKrLrMrOrPrQrTrSrUrV)rrrrs    rto_jsonzSpan.to_jsons
|"1&*&A'+#3	
	
;	/#';DJx z	BvJz	BvJ	rcj|j|j|j|j|jd}|jr
|j|d<|S)N)rJrKrLrOrPrS)rJrKrLrOrPrS)rrs  rget_trace_contextzSpan.get_trace_contextsG
|"1'+

;	';BxL	r)
NNNTNNNNNNr)r7r8r9rGr]rrkrtr}rrrclassmethodrrrrrrrrrrrrrr)rrrIrIesI,### #',',',',R&&&





			2***TT[T*[4444.
.
[.
`CCC      ---B###&4rrIcBeZdZdZ		d	dZdZd
dZfdZdZxZ	S)r^)namerrNc|s-d|vr)tjd|d}tj|fi|||_||_dS)Nr[z^Deprecated: use Transaction(name=...) to create transactions instead of Span(transaction=...).)rrpoprIrrr)rrrr`s    rrzTransaction.__init__so	-
//N4


::m,,D
d%%f%%%	,rcd|jjd|jd|jd|jd|jd|jd|jdS)	Nrmz(name=z, op=rnrorprqrr)rsr7rrOrJrKrLrNr.s rrtzTransaction.__repr__sW
N###IIIGGGMMMLLLLLL
	
rc
jdSjtjddS|pjpt
jj}|j}|dSj	stj
dd_	t|j
sj
tj
ddSfdjjD}|dj	dijjj|dS)	Nz.Discarding transaction because sampled = FalsezCTransaction has no name, falling back to `<unlabeled transaction>`.z<unlabeled transaction>z1Discarding transaction without sampling decision.cNg|]!}|u|j
|"Sr)rTr)r*rDrs  r
<listcomp>z&Transaction.finish.<locals>.<listcomp>s=


4DN$>
LLNN$>$>$>rr[trace)typer[contextsrrTrQr>)rTrBrdebugrWrwrxryclientrrrIrrNr>
capture_eventrrUrQ)rrWrfinished_spanss`   rrzTransaction.finishsA>%4&LIJJJ47TX7!7>4y	2NU


2DID#|	|#RSSS4



+1


  %#y$d&<&<&>&>?
!^#'#7'






	
rctt|}|j|d<|j|d<|j|d<|S)NrrNr)superr^rrrNr)rrrss  rrzTransaction.to_json+sG
;
%
%
-
-
/
/Y6
9
#2	rc
|jptjj}|j}|r|jpi}d|jr
d|jzdznd|j}|rt|s	d|_
dS|j
dSt|dr|d|n|d	|d	n|d
}t|s1tjd|d|_
dS|sVtjd
|t|drdndd|_
dSt#jt%|k|_
|j
r*tjd|dStjd|t%|dS)aP
        Sets the transaction's sampling decision, according to the following
        precedence rules:

        1. If a sampling decision is passed to `start_transaction`
        (`start_transaction(name: "my transaction", sampled: True)`), that
        decision will be used, regardlesss of anything else

        2. If `traces_sampler` is defined, its decision will be used. It can
        choose to keep or ignore any parent sampling decision, or use the
        sampling context data to make its own decision or to choose a sample
        rate for the transaction.

        3. If `traces_sampler` is not defined, but there's a parent sampling
        decision, the parent sampling decision will be used.

        4. If `traces_sampler` is not defined and there's no parent sampling
        decision, `traces_sample_rate` will be used.
        z{op}transaction <{name}>rmz> r)rOrFNtraces_samplerrtraces_sample_ratezN[Tracing] Discarding {transaction_description} because of invalid sample rate.)transaction_descriptionz?[Tracing] Discarding {transaction_description} because {reason}z"traces_sampler returned 0 or Falseztraces_sample_rate is set to 0)rreasonz,[Tracing] Starting {transaction_description}z}[Tracing] Discarding {transaction_description} because it's not included in the random sample (sampling rate = {sample_rate}))rsample_rate)rWrwrxryroptionsrrOrhas_tracing_enabledrNcallabler_is_valid_sample_raterrrrandomfloat)rsampling_contextrWrrrrs       r_set_initial_sampling_decisionz*Transaction._set_initial_sampling_decision5sl,h0*.0,fn3"<"C"C(,7dg
$$Rty#D#
#

	099	 DLF<#F$45566
%G$%&6777
$$45A!!12212	%[11	N`gg,Ch



!DLF	LQXX,C$GKK0@$A$ABB><<=Y	
	
	
!DLF
}{););;<	L>EE,CF





LPWW,C %k 2 2W




r)rNr)
r7r8r9rGrrtrrr
__classcell__)rss@rr^r^s*I----(





1
1
1
1
fbbbbbbbrr^cpt|dp|dS)zo
    Returns True if either traces_sample_rate or traces_sampler is
    non-zero/defined, False otherwise.
    rr)boolr)rs rrrs1011RW[[AQ5R5RSSSrcRt|trtj|r8t	jd|t|dSt|}|dks|dkr*t	jd|dSdS)	z
    Checks the given sample rate to make sure it is valid type and value (a
    boolean or a number between 0 and 1, inclusive).
    z}[Tracing] Given sample rate is invalid. Sample rate must be a boolean or a number between 0 and 1. Got {rate} of type {type}.)raterFrr(zX[Tracing] Given sample rate is invalid. Sample rate must be between 0 and 1. Got {rate}.rT)	r1rmathisnanrrrrrrs rrrsdD!!TZ%5%5
L
S
ST


S

	
	
	

u;;Daxx4!88fmm
n

	
	
	

u4rcd}	t|drI||}t|tr||jj}n#t$rd}YnwxYw|pt|S)Nmogrify)	hasattrrr1bytesdecode
connectionencoding	Exceptionr)cursorsqlreal_sqls   r_format_sqlrsH69%%	G~~c**H(E**
G#??6+<+EFF%y~~%sAAA-,A-c#&K|jr:|jjdddr|r|dgkrd}|dkrd}nd}d}t||}i}|||d<|||d<|rd|d	<t	5||d
|dddn#1swxYwY|d|
5}|D]\}}	|||	|VddddS#1swxYwYdS)N_experimentsrecord_sql_paramsFpyformatrz	db.paramsz
db.paramstyleTzdb.executemanyquery)messagecategoryrdb)rOrP)	rrrrradd_breadcrumb
start_spanitemsr)
rWrrparams_list
paramstyleexecutemanyrrDr5vs
          rrecord_sql_queriesrsz
cj(8<<U
	kdV33K##!J
&&E
D'[ *_&!%
	$	&	&GG57FFFGGGGGGGGGGGGGGG

4U	3	3tJJLL	 	 DAqMM!Q


s$=B""B&)B&5DD

D
c|jdkr%||jdd|jdS|jdkr|dd|jdS|jdkr%|dd|j|jdSdS)Nredis)rrrrhttphttplib)rrr
subprocess)rrrr)rOrrPrUrV)rWrDs  rrrsw'$7W4:		
	
	
	
	

F		LLLLL	
L	 	 !$			
	
	
	
	

!	 r)+rerc
contextlibrrrgrrnumbersrrwsentry_sdk.utilsrrrsentry_sdk._compatr	sentry_sdk._typesr
collectionsrcollections.abctypingrr
rrrrrcompilerrr\r;rIr^rrrcontextmanagerrrr)rr<module>r s				



((((((((
#"""""""""""(#######''''''
2MMM      111111 *
!!(((((W(((>$$$$$F$$$.mmmmm6mmm`BBBBB$BBBJTTT>&&&('''T




r
Back to Directory File Manager