/var/opt/nydus/ops/mysql/connector/opentelemetry/__pycache__
NameSizeModeActions
constants.cpython-312.pyc11410644editdlrm
context_propagation.cpython-312.pyc34410644editdlrm
instrumentation.cpython-312.pyc295750644editdlrm
__init__.cpython-312.pyc1840644editdlrm
Edit: /var/opt/nydus/ops/mysql/connector/opentelemetry/__pycache__/instrumentation.cpython-312.pyc (29575B)
N jaNUdZddlmZddlZddlZddlmZmZddlm Z ddl m Z m Z m Z mZmZmZmZe rddlmZmZdd lmZd d lmZdd lmZmZdd lmZddlmZ ddlm Z ddl!m"Z"ddl#m$Z$ddlm)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4ejjdZ6de7d<d(dZ8d)dZ9d*dZ: d+ d,dZ;d-dZGdd eZ?Gd!d"e?Z@Gd#d$e?ZA d+ d.d%ZBGd&d'ZCy#e%$r!Z&ejNjQde&dZ&[&wwxYw)/z1MySQL instrumentation supporting mysql-connector.) annotationsN)ABCabstractmethod) nullcontext) TYPE_CHECKINGAnyCallable CollectionDictOptionalUnion)MySQLConnectionAbstractMySQLCursorAbstract)PooledMySQLConnection) connector) CNX_POOL_ARGSDEFAULT_CONFIGURATION)logger) VERSION_TEXT)trace)TracerProvider)SpanAttributeszGOpenTelemetry installation not found. You must install the API and SDK.) CONNECTION_SPAN_NAME DB_SYSTEMDEFAULT_THREAD_IDDEFAULT_THREAD_NAMEFIRST_SUPPORTED_VERSIONNET_SOCK_FAMILYNET_SOCK_HOST_ADDRNET_SOCK_HOST_PORTNET_SOCK_PEER_ADDRNET_SOCK_PEER_PORTOPTION_CNX_SPANOPTION_CNX_TRACERz ^/\*.*?\*/z re.Patternleading_comment_removerc|r|jr|sy|jtjtjj |j |y)zRecords an exeception event.N) is_recording set_statusrStatus StatusCodeERRORrecord_exception)spanexcs ^/opt/nydus/tmp/pip-target-a90h98xg/lib/python/mysql/connector/opentelemetry/instrumentation.pyrecord_exception_eventr3XsD t((*#OOELL!1!1!7!789#cJ|r|jsy|jy)z Ends span.N)r*end)r0s r2end_spanr7as t((*HHJr4cv|r7t|tr'tjd|j dSy)z&Parse query to extract operation name.r) isinstancestrr(subsplit) operations r2get_operation_namer?is2Z 3/&**2y9??A!DD r4c|r|jsy|i}|r |j nd|v}tjttj|rdndt |rdndi}|r |r |j n|jdtd|tj<|r |jn|jdtd|tj<t|d r|jr |jjj\|t <}|jjj#\|t$<|t&<|tj|k7rt||t(<nj|r |jn|jd|t <t|d r8|jr, |jjj#|t$<|j1|y#t*$r }t-j.d |Yd}~6d}~wwxYw#t*$r }t-j.d |Yd}~bd}~wwxYw) aDefines connection span attributes. If `cnx` is None then we use `cnx_kwargs` to get basic net information. Basic net attributes are defined such as: * DB_SYSTEM * NET_TRANSPORT * NET_SOCK_FAMILY Socket-level attributes [*] are also defined [**]. [*]: Socket-level attributes identify peer and host that are directly connected to each other. Since instrumentations may have limited knowledge on network information, instrumentations SHOULD populate such attributes to the best of their knowledge when populate them at all. [**]: `CMySQLConnection` connections have no access to socket-level details so socket-level attributes aren't included. `MySQLConnection` connections, on the other hand, do include socket-level attributes. References: [1]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/ specification/trace/semantic_conventions/span-general.md N unix_socketip_tcpinprocinetunixhostport_socketzConnection socket is down %s)r* _unix_socketrr NET_TRANSPORTr!_hostgetr NET_PEER_NAME_port NET_PEER_PORThasattrrHsock getpeernamer$ getsocknamer"r#r% Exceptionrwarningset_attributes)cnxcnx_span cnx_kwargsis_tcpattrssock_peer_portsock_errs r2set_connection_span_attrsr^qs8 8002 %(!! !m:.MF   )$$&hh6vECII*..9Nv9V"W n**+CII*..9Nv9V"W n**+ 3 "s{{ ?KK$$002,-" KK$$002,-,- 556.H1?E,- !$C   )F  ! 3 "s{{ I,/KK,<,<,H,H,J() E") I=xHH I" I=xHH Is1+A#G*-+H* H3HH H?H::H?cdfd }|S)zAAttach the connection span while executing the connection method.c|jr;|jjr!tj|jdn t 5|g|i|cdddS#1swYyxYw)z#Connection span attacher decorator.F end_on_exitN)_spanr*ruse_spanr)rWargskwargsmethods r2wrapperz'with_cnx_span_attached..wrappersdYY399113^^ II5 9DG#///GGGs  A))A2)rW'MySQLConnectionAbstract'rerrfrreturnrrgrhs` r2with_cnx_span_attachedrms0 Nr4cdfd }|S)z:Create a query span while executing the connection method.c tjdjtjttj |j tjttjtd|ji}|jr|jjr{|jjjj!t"j$j&t#j(|jj+g|n t-5|g|i|cdddS#1swYyxYw)Query span creator decorator.z%Creating query span for connection.%sconnection_typenamekindlinks attributesN)rinfo__name__rrDB_USER_user THREAD_IDr THREAD_NAMErget_wrapped_classrcr*_tracerstart_as_current_spanupperrSpanKindCLIENTLinkget_span_contextr)rWrerfquery_span_attributesrgs r2rhz$with_cnx_query_span..wrappers ;V__M  $ $i  " "CII  $ $&7  & &(; s446 ' YY399113 [[ . .&&(&&::cii88:;<, / :E G #/// GGGs 5 E  E)rWTracedMySQLConnectionrerrfrrjrrkrls` r2with_cnx_query_spanrs0( Nr4cdfd }|S)z6Create a query span while executing the cursor method.c tjdjt|jdrt |jdnt |jd}t jtt j|jt jtt jtd|ji}|jj!t#|dxsdt$j&j(|j*g|5|g|i|cdddS#1swYyxYw) rpz!Creating query span for cursor.%s _connection_cnx cursor_typerz SQL statementrrN)rrwrxrP_wrappedgetattrrrryrzr{rr|rr}r~rr?rrr_connection_span_link)currerf connectionrrgs r2rhz'with_cursor_query_span..wrappers 7Is||]3 CLL- 0v.   $ $i  " "J$4$4  $ $&7  & &(; 3002 ' [[ . .#DG,?&&,,-, / #///    s  D44D=)rTracedMySQLCursorrerrfrrjrrkrls` r2with_cursor_query_spanrs04 Nr4cVeZdZdZeddZd dZd fd Zd dZd dZ d dZ xZ S)BaseMySQLTracerzs/07 %+ 16  , , .2 "r4c:|jj|i|SInstrument method.)rexecuters r2rzTracedMySQLCursor.executeKs %t}}$$d5f55r4c:|jj|i|Sr)r executemanyrs r2rzTracedMySQLCursor.executemanyP )t}}(($9&99r4c:|jj|i|Sr)rcallprocrs r2rzTracedMySQLCursor.callprocU &t}}%%t6v66r4N)rz'MySQLCursorAbstract'rz trace.Tracerr trace.Spanrerrfrrjr) rxrrrrrrrrrkr4r2rr;sbE  &    $  66::77r4rcpeZdZdZd"dZd#dZed$dZed$dZed$dZ ed$dZ ed$dZ ed$d Z ed$d Z ed$d Zed$d Zed$d Zed$dZed$dZeed%dZed$dZed$dZed$dZed$dZed$dZed$dZed$dZed$dZed$dZed$dZeed%dZeed%dZ eed&dZ!e!jDed'dZ!ed$dZ#ed$d Z$y!)(rzCWrapper class for a `MySQLConnection` or `CMySQLConnection` object.c>||_|jj}yrrsql_mode)rr_s r2rzTracedMySQLConnection.__init__^s3:  MM " "r4czt|jj|i||j|jS)zWraps the object method.)rrr)rrcursorr~rcrs r2rzTracedMySQLConnection.cursorfs6 (DMM(($9&9<< JJ  r4c:|jj|i|Sr)rcmd_change_userrs r2rz%TracedMySQLConnection.cmd_change_userns -t}},,d=f==r4c:|jj|i|Sr)rcommitrs r2rzTracedMySQLConnection.commitss $t}}##T4V44r4c:|jj|i|Sr)rrollbackrs r2rzTracedMySQLConnection.rollbackxrr4c:|jj|i|Sr)r cmd_queryrs r2rzTracedMySQLConnection.cmd_query} 't}}&&777r4c:|jj|i|Sr)r cmd_init_dbrs r2rz!TracedMySQLConnection.cmd_init_dbrr4c:|jj|i|Sr)r cmd_refreshrs r2rz!TracedMySQLConnection.cmd_refreshrr4c:|jj|i|Sr)rcmd_quitrs r2rzTracedMySQLConnection.cmd_quitrr4c:|jj|i|Sr)r cmd_shutdownrs r2rz"TracedMySQLConnection.cmd_shutdown *t}}))4:6::r4c:|jj|i|Sr)rcmd_statisticsrs r2rz$TracedMySQLConnection.cmd_statistics ,t}}++Tv>>r4c:|jj|i|Sr)r cmd_debugrs r2rzTracedMySQLConnection.cmd_debugrr4c:|jj|i|Sr)rcmd_pingrs r2rzTracedMySQLConnection.cmd_pingrr4c.|jjSr)rdatabasers r2rzTracedMySQLConnection.database}}%%%r4c:|jj|i|Sr)r is_connectedrs r2rz"TracedMySQLConnection.is_connectedrr4c:|jj|i|Sr)r reset_sessionrs r2rz#TracedMySQLConnection.reset_sessions +t}}**D;F;;r4c:|jj|i|Sr)rpingrs r2rzTracedMySQLConnection.pings "t}}!!42622r4c:|jj|i|Sr)r info_queryrs r2rz TracedMySQLConnection.info_querys (t}}''888r4c:|jj|i|Sr)rcmd_stmt_preparers r2rz&TracedMySQLConnection.cmd_stmt_preparerr4c:|jj|i|Sr)rcmd_stmt_executers r2rz&TracedMySQLConnection.cmd_stmt_executerr4c:|jj|i|Sr)rcmd_stmt_closers r2rz$TracedMySQLConnection.cmd_stmt_closerr4c:|jj|i|Sr)rcmd_stmt_send_long_datars r2rz-TracedMySQLConnection.cmd_stmt_send_long_datas 5t}}44dEfEEr4c:|jj|i|Sr)rcmd_stmt_resetrs r2rz$TracedMySQLConnection.cmd_stmt_resetrr4c:|jj|i|Sr)rcmd_reset_connectionrs r2rz*TracedMySQLConnection.cmd_reset_connections 2t}}114B6BBr4c.|jjSr)r time_zoners r2rzTracedMySQLConnection.time_zones}}&&&r4c.|jjSrrrs r2rzTracedMySQLConnection.sql_moderr4c.|jjSrrrrs r2rz TracedMySQLConnection.autocommits}}'''r4c&||j_y)rNr)rrs r2rz TracedMySQLConnection.autocommits$)  r4c:|jj|i|Sr)rset_charset_collationrs r2rz+TracedMySQLConnection.set_charset_collations 3t}}22DCFCCr4c:|jj|i|Sr)rstart_transactionrs r2rz'TracedMySQLConnection.start_transactions /t}}..???r4N)rrirjr)rerrfrrjrrr)rjbool)rrrjr)%rxrrrrrrrrrrrrrrrrrrpropertyrrrrrrrrrrrrrrsetterrrrkr4r2rr[sM# >>557788::::77;;==??8877&&;;<<3399????==FF==CC''&&(())DD@@r4rcTtj dfd }|S)z.Retrurn the instrumented version of `connect`.ctfdtDrtjd|iSt j dt }|jttjjt<|t<t jtd5}td||i}t||t| cdddS#1swYyxYw) zWraps the connection object returned by the method `connect`. Instrumentation for PooledConnections is not supported. c3&K|]}|v ywNrk).0keyrfs r2 z7_instrument_connect..wrapper..s6 sf} sz4Instrumentation for pooled connections not supportedMySQL Connector/Pythoninstrumenting_module_nameinstrumenting_library_versiontracer_providerrsrtFraNr)anyrrrUr get_tracerr start_spanrrrr&r'rdr^r)rerfrrXrWconnectrs ` r2rhz$_instrument_connect..wrapper s 6 6 6 NNQ RD+F+ +!!&>*6+ #)"3"3%ENN,A,A#4# %+ !^^F?3 G8 %dHf =4*6*C &c8V <(H G Gs 1.C))C2)rerrfrrjz9Union['MySQLConnectionAbstract', 'PooledMySQLConnection']) functoolswraps)rrrhs`` r2_instrument_connectrs@__W''!' B''R Nr4cfeZdZUdZdZded<d dZd dZd dZ d ddZ d d Z dd Z y)MySQLInstrumentorz8MySQL instrumentation supporting mysql-connector-python.NzOptional[MySQLInstrumentor] _instancec|jCtj|g|i||_t|jdtj |jS)zQSinglenton. Restricts the instantiation to a singular instance. _original_connect)r!object__new__setattrrr)clsrerfs r2r%zMySQLInstrumentor.__new__>sI == "NN3@@@CM CMM#6 8I8I J}}r4cdtgS)zoReturn a list of python packages with versions that the will be instrumented (e.g., versions >= 8.1.0).zmysql-connector-python >= )r rs r2instrumentation_dependenciesz.MySQLInstrumentor.instrumentation_dependenciesJs--D,EFGGr4c tjt|dk7rtjdyt t|d|j dt_y)aInstrument the library. Args: trace_module: reference to the 'trace' module from opentelemetry. tracer_provider (optional): TracerProvider instance. NOTE: Instrumentation for pooled connections not supported. r#z3MySQL Connector/Python module already instrumented.Nr)rr)rrrrrUrrLrrfs r2 instrumentzMySQLInstrumentor.instrumentOsO   .A B B NNP Q /D"56"JJ'89 r4ct|trtjd|St |dr t |ds,tjd|j j |Stjdt|}|jttjj|_||_t!||jt|S) aEnable instrumentation in a MySQL connection. Args: connection: uninstrumented connection instance. trace_module: reference to the 'trace' module from opentelemetry. tracer_provider (optional): TracerProvider instance. Returns: connection: instrumented connection instace. NOTE: Instrumentation for pooled connections not supported. z Connection already instrumented.rcr~z+Instrumentation for class %s not supported.rrrr)r:rrrUrPrrxrrrrrrrrcr~r^)rrrrs r2instrument_connectionz'MySQLInstrumentor.instrument_connection`s" j"7 8 NN= > z7+7:y3Q NN=$$--  !!&>*6+  ",,%ENN,A,A- $ !*j.>.>?$Z88r4c tjt|dk(rtjdyt|dt_y)zUninstrument the library.r#z5MySQL Connector/Python module already uninstrumented.N)rrrrrUr+s r2 uninstrumentzMySQLInstrumentor.uninstruments:   .A B B NNR S #D*=> r4cft|ds,tjd|jj|St |t stjd|S|jr;|jjr!|jjd|_|jS)aDisable instrumentation in a MySQL connection. Args: connection: instrumented connection instance. Returns: connection: uninstrumented connection instace. NOTE: Instrumentation for pooled connections not supported. rcz-Uninstrumentation for class %s not supported.z"Connection already uninstrumented.N) rPrrUrrxr:rrcr*r6r)rrs r2uninstrument_connectionz)MySQLInstrumentor.uninstrument_connectionsz7+ NN?$$--  *&;< NN? @     0 0 = = ?    "#J """r4)rerrfrrjr )rjzCollection[str])rfrrjrr )rrirOptional[trace.TracerProvider]rjri)rrirjri) rxrrrr!__annotations__r%r)r,r.r0r2rkr4r2r r 9saB-1I*1 H  (;?(9-(98(9 # (9T?#3# "#r4r )r0rr1zOptional[Exception]rjr)r0rrjr)r>r;rjr;r )rWz#Optional['MySQLConnectionAbstract']rXrrYzOptional[Dict[str, Any]]rjr)rgr rjr )rHCallable[..., Union['MySQLConnectionAbstract', 'PooledMySQLConnection']]rr3rjr5)Dr __future__rrreabcrr contextlibrtypingrrr r r r r abstractsrrpoolingrr9r constantsrrrversionr opentelemetryropentelemetry.sdk.traceropentelemetry.semconv.tracer ImportErrormissing_dependencies_errerrorsProgrammingErrorrrrrr r!r"r#r$r%r&r'compiler(r4r3r7r?r^rmrrrrrrr rkr4r2rGs\:8# #"RRRI/<" $$6:    '1bjj&??,0R# ,R#R#)R# R#j 4@+0c+0\77@g@Og@X7;1 U131N1hv#v#s$    + +Q  #$$sC>>D$DD$