JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrJFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr 0i! ddlZddlZddlZddlZddlZddlZddlZddlZddl m Z m Z ddl m Z e rddl mZddl mZddl mZddl mZddl mZdd lmZmZmZdd lmZej4d Zd Zd ZGddZ ddlmZddl m!Z!m"Z"m#Z#ddl$m%Z%dZ&dZ'dZ(dZ)dZ*e+de e,e*j[e*j]DZ/GddeZ0dZ2y#e1$rdZ%YdZ2ywxYw)N)chainproduct) TYPE_CHECKING)Any)Callable)Dict)Optional)Self)logger env_to_boolcapture_internal_exceptions)Envelope spotlightzhttp://localhost:8969/streamz(sentry_sdk.spotlight.SpotlightMiddlewareceZdZdZdZy)SpotlightClientcR||_tj|_d|_y)Nr)urlurllib3 PoolManagerhttpfails)selfrs C/opt/hc_python/lib/python3.12/site-packages/sentry_sdk/spotlight.py__init__zSpotlightClient.__init__%s '')  c(tj}|j| |jj |j |j dddi}|jd|_y#t$r}|jdkr4tjt||xjdz c_nC|jdk(r/|xjdz c_tjdYd}~yYd}~yYd}~yd}~wwxYw) NPOST Content-Typezapplication/x-sentry-envelope)rbodymethodheadersrz]Looks like Spotlight is not running, will keep trying to send events but will not log errors.) ioBytesIOserialize_intorrequestrgetvaluecloser Exception sentry_loggerwarningstr)renveloperreqes rcapture_envelopez SpotlightClient.capture_envelope+szz|% ))##HH]]_"$C $C IIKDJ zzA~%%c!f- a q a %%s! sAA88 DAwindow.__spotlight = {{ initOptions: {{ sidecarUrl: '{spotlight_url}', fullPage: false }} }}; z zcharset=rc#\K|]$}djdj|&yw)zN)formatjoin).0charss r rAWs))PE rwwu~&Ps*,cBeZdZdZdZfdZedZdZdZ xZ S)SpotlightMiddlewareNc$t||ddl}|j|_|jj j }|tjdytjj|jd|_ y)NrzPCannot find Spotlight client from SpotlightMiddleware, disabling the middleware.z../)superrsentry_sdk.apiapi sentry_sdk get_clientrr+r,urllibparseurljoinr_spotlight_url)r get_responserHspotlight_client __class__s rrzSpotlightMiddleware.__init__`ss G \ * !(nnDO#99;EE '%%f"(,,"6"67G7K7KU"SD rc&|j|j tjj |jt }tj j|d}tj j|tj|j||_|jS|jS#tjj$r-}tjd|Yd}~|jSd}~wwxYw)NHEAD)r ) spotlight_urlspotlight_js_urlzUCannot get Spotlight JS to inject at %s. SpotlightMiddleware will not be very useful.)exc_info)rM_spotlight_scriptrJrKrLSPOTLIGHT_JS_ENTRY_PATHr'RequesturlopenSPOTLIGHT_JS_SNIPPET_PATTERNr=errorURLErrorr+debug)rrTr/errs rspotlight_scriptz$SpotlightMiddleware.spotlight_scriptqs"".43I3I3Q'-||';';++-D($!..00(%1CNN**3/-I-P-P&*&9&9)9.Q.D*)) )4)) )||,,!''o(!$ )) )sBCD#D  Dctdjjddjj dD}|d}t |dkDr.|dj tr|dt tdnd|jjs|dk(rt j}|jj}td fd tDD|}jd||zj|dz_ jd r|t |zjd <S) Nc3<K|]}|jywN)strip)r?ps rrAz7SpotlightMiddleware.process_response..s(TA Tsrr<;rr#utf-8z text/htmlc3*K|] }|dkDr| yw)Nr5)r?idxs rrAz7SpotlightMiddleware.process_response..s%$C8 $sc3rK|].}jj|j0ywrb)contentrfindencode)r? body_variantencodingresponses rrAz7SpotlightMiddleware.process_response..s5$0L %,,22<3F3Fx3PQ0Ls47zContent-Length)tupler!getlowersplitlen startswithCHARSET_PREFIXr_ streamingrkrmnextBODY_CLOSE_TAG_POSSIBILITIES has_header) r_requestrpcontent_type_header content_typecontent_length injectioninjection_siteros ` @rprocess_responsez$SpotlightMiddleware.process_responsesc"'(!))--nbAGGIOOPST(# /q1L&'!+0CA0F0Q0Q1/q1#n2E2GH"%%1 ** K/!$X%5%5!6 1188B !%$0L$# "$$_n5 &&~78 &&'789G#i.9XH$$%56Orc tjr |jsy tjj |jj jd}|jj|}t|jdtj|j|S#tjj$rYywxYw)Nrfz)rSevent_id)r:DEBUGrMrJr'rYreaddecoderHcapture_exceptionr7replaceSPOTLIGHT_ERROR_PAGE_SNIPPETr=r[r\)rr| exceptionrrs rprocess_exceptionz%SpotlightMiddleware.process_exceptions>>)<)< NN**4+>+>?DDFMMgV  ??<t-|t/|t*ft_t j1ddddt3|}t j1d||S#1swY,xYw) Nz' [spotlight] %(levelname)s: %(message)srTSENTRY_SPOTLIGHT_ON_ERROR1SENTRY_SPOTLIGHT_MIDDLEWAREz(Enabled Spotlight integration for Djangoz%Enabled Spotlight using sidecar at %s)logging StreamHandlersysstderr setFormatter Formatterr addHandlersetLevelINFOrrDEFAULT_SPOTLIGHT_URL isinstancer-r r:rr osenviron MIDDLEWARE DJANGO_SPOTLIGHT_MIDDLEWARE_PATHtyperinfor)options_handlerr middlewareclients rsetup_spotlightrs*$$SZZ0H '++,UVW h OOGLL! ++k "C d{# c3  $ &  BJJNN+FLMBJJNN+H#NO!,,J/zA&6d:&6*'G&IJ'# FG 'S !F KK7= M# ' &s 6B?F  F))3r$rr urllib.parserJurllib.request urllib.errorrr itertoolsrrtypingrrrrr r sentry_sdk.utilsr r+r r sentry_sdk.enveloper getLoggerrrrdjango.utils.deprecationr6 django.httpr7r8r9 django.confr:rWrZrrw BODY_TAG_NAMErqzipupperrsrzrC ImportErrorrr5rrrs   $  )   ; '7#M FH8NN$/ Q!  {! NM#()c-"5"5"79L9L9NOP)$ popl  H  sA C$$C10C1