• File: scope.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib/python3.7/site-packages/sentry_sdk/__pycache__/scope.cpython-37.pyc
  • Date Modified: 07/08/2021 12:27 AM
  • File size: 9.69 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

Z~_w>@sFddlmZddlmZddlmZddlmZddlmZddl	m
Z
mZddlm
Z
ddlmZerdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZmZmZmZmZmZmZddlmZddl m!Z!ededefdZ"edZ#gZ$ddZ%ddZ&ddZ'Gddde(Z)dS) )copy)deque)chain)wraps)MYPY)loggercapture_internal_exceptions)Transaction)
Attachment)Any)Dict)Optional)Deque)List)Callable)TypeVar)
BreadcrumbEventEventProcessorErrorProcessorExcInfoHintType)Span)SessionF.)ZboundTcCst|dS)N)global_event_processorsappend)Z	processorrA/opt/alt/python37/lib/python3.7/site-packages/sentry_sdk/scope.pyadd_global_event_processor(sr!cCst||jdS)N)fsetdoc)property__doc__)fnrrr _attr_setter-sr'cstfdd}|S)Ncs.|js
dSzd|_|f||Sd|_XdS)NFT)_should_capture)selfargskwargs)r&rr wrapper4sz!_disable_capture.<locals>.wrapper)r)r&r,r)r&r _disable_capture2sr-c@seZdZdZdZddZddZeddZd	d
Z	eddZ
ed
dZej
ddZeddZddZeddZej
ddZddZddZddZddZdd Zd!d"Zd#d$Zd7d'd(Zd)d*Zd8d+d,Zed-d.Zd/d0Zd9d1d2Zd3d4Zd5d6Z d%S):ScopezaThe scope holds extra information that should be sent with all
    events that belong to it.
    )_level_name_fingerprint_transaction_user_tags	_contexts_extras_breadcrumbs_event_processors_error_processorsr(_span_session_attachments_force_auto_session_trackingcCsg|_g|_d|_|dS)N)r8r9r0clear)r)rrr __init__bszScope.__init__cCsTd|_d|_d|_d|_i|_i|_i|_g|_|d|_	d|_
d|_d|_dS)zClears the entire scope.NT)
r/r1r2r3r4r5r6r<clear_breadcrumbsr(r:r;r=)r)rrr r>jszScope.clearcCs
||_dS)zDWhen set this overrides the level. Deprecated in favor of set_level.N)r/)r)valuerrr level~szScope.levelcCs
||_dS)zSets the level for the scope.N)r/)r)rArrr 	set_levelszScope.set_levelcCs
||_dS)z0When set this overrides the default fingerprint.N)r1)r)rArrr fingerprintszScope.fingerprintcCs4|jdkrdSt|jtr |jS|jjr0|jjSdS)z8Return the transaction (root span) in the scope, if any.N)r:
isinstancer	Z_containing_transaction)r)rrr transactions
zScope.transactioncCs$||_|j}|r t|tr ||_dS)z;When set this forces a specific transaction name to be set.N)r2r:rEr	name)r)rAspanrrr rFscCs||dS)zPWhen set a specific user is bound to the scope. Deprecated in favor of set_user.N)set_user)r)rArrr usersz
Scope.usercCs"||_|jdk	r|jj|ddS)zSets a user for the scope.N)rJ)r3r;update)r)rArrr rIs
zScope.set_usercCs|jS)z,Get/set current tracing span or transaction.)r:)r)rrr rHsz
Scope.spancCs&||_t|tr"|}|jr"|j|_dS)N)r:rEr	rGr2)r)rHrFrrr rHs

cCs||j|<dS)z)Sets a tag for a key to a specific value.N)r4)r)keyrArrr set_tagsz
Scope.set_tagcCs|j|ddS)zRemoves a specific tag.N)r4pop)r)rLrrr 
remove_tagszScope.remove_tagcCs||j|<dS)z5Binds a context at a certain key to a specific value.N)r5)r)rLrArrr set_contextszScope.set_contextcCs|j|ddS)zRemoves a context.N)r5rN)r)rLrrr remove_contextszScope.remove_contextcCs||j|<dS)z&Sets an extra key to a specific value.N)r6)r)rLrArrr 	set_extraszScope.set_extracCs|j|ddS)zRemoves a specific extra key.N)r6rN)r)rLrrr remove_extraszScope.remove_extracCst|_dS)zClears breadcrumb buffer.N)rr7)r)rrr r@szScope.clear_breadcrumbsNFc	Cs|jt|||||ddS)z)Adds an attachment to future events sent.)bytespathfilenamecontent_typeadd_to_transactionsN)r<rr
)r)rTrVrUrWrXrrr add_attachment
s
zScope.add_attachmentcCs8t|jdkr(td|j|jdd=|j|dS)z}Register a scope local event processor on the scope.

        :param func: This function behaves like `before_send.`
        zLToo many event processors on scope! Clearing list to free up some memory: %rN)lenr8rZwarningr)r)funcrrr add_event_processor!szScope.add_event_processorcs.|dk	r||fdd}|j|dS)aRegister a scope local error processor on the scope.

        :param func: A callback that works similar to an event processor but is invoked with the original exception info triple as second argument.

        :param cls: Optionally, only process exceptions of this type.
        Ncs>yt|d}Wntk
r*d}YnX|r:||S|S)NF)rE	Exception)eventexc_infoZis_inst)cls_	real_funcrr r\Bs

z'Scope.add_error_processor.<locals>.func)r9r)r)r\clsr)rbrcr add_error_processor2s

zScope.add_error_processorc
Csdd}|ddk}|dp"g}x"|jD]}|r:|jr,||q,W||d<|jdk	rd|j|d<|s|did	g|j|d
dkr|jdk	r|j|d
<|ddkr|j	dk	r|j	|d<|ddkr|j
dk	r|j
|d<|jr|di|j|j
r"|d
i|j
|jr>|di|j|jdk	rp|di}|dsp|j|d<|d}|dk	rx4|jD]*}	|	||}
|
dkr|||	dS|
}qWxPtt|jD]@}|}
t|||}
WdQRX|
dkr|||dS|
}qW|S)zBApplies the information contained on the scope to the given event.cSstd|||dS)Nz%s (%s) dropped event (%s))rinfo)r`causeZtyrrr _dropWsz#Scope.apply_to_event.<locals>._droptyperFZattachmentsNrBZbreadcrumbsvaluesrJrDZextratagscontextsZtracerazerror processorzevent processor)getr<rXrr/
setdefaultextendr7r3r2r1r6rKr4r5r:Zget_trace_contextr9rrr8r)r)r`ZhintrhZis_transactionZattachments_to_sendZ
attachmentrlraZerror_processorZ	new_eventZevent_processorrrr apply_to_eventNsV	












zScope.apply_to_eventcCs|jdk	r|j|_|jdk	r$|j|_|jdk	r6|j|_|jdk	rH|j|_|jr\|j|j|jrp|j|j|jr|j|j|jr|j	|j|j
r|j
|_
|jr|j	|jdS)N)r/r1r2r3r4rKr5r6r7ror:r<)r)Zscoperrr update_from_scopes(



zScope.update_from_scopecCsj|dk	r||_|dk	r||_|dk	r0|j||dk	rD|j||dk	rX|j||dk	rf||_dS)N)r/r3r6rKr5r4r1)r)rJrBZextrasrlrkrDrrr update_from_kwargss
zScope.update_from_kwargscCst|j}|j|_|j|_|j|_|j|_|j|_t|j	|_	t|j
|_
t|j|_t|j
|_
t|j|_t|j|_|j|_|j|_|j|_|j|_t|j|_|S)N)object__new__	__class__r/r0r1r2r3dictr4r5r6rr7listr8r9r(r:r;r=r<)r)rvrrr __copy__s$zScope.__copy__cCsd|jjtt||jfS)Nz<%s id=%s name=%s>)ru__name__hexidr0)r)rrr __repr__s
zScope.__repr__)NNNNF)N)NNNNNN)!rz
__module____qualname__r%	__slots__r?r>r'rBrCrDr$rFsetterrJrIrHrMrOrPrQrRrSr@rYr]rer-rprqrrryr}rrrr r.BsJ				

J
r.N)*rcollectionsr	itertoolsrZsentry_sdk._functoolsrZsentry_sdk._typesrZsentry_sdk.utilsrrZsentry_sdk.tracingr	Zsentry_sdk.attachmentsr
typingrrr
rrrrrrrrrrrrZsentry_sdk.sessionsrrrrr!r'r-rsr.rrrr <module>s2$