HEX
Server: LiteSpeed
System: Linux us-phx-web1284.main-hosting.eu 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: u300739242 (300739242)
PHP: 8.2.30
Disabled: system, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //opt/alt/python311/lib/python3.11/site-packages/botocore/__pycache__/monitoring.cpython-311.pyc
�

/�;fuP�� �ddlZddlZddlZddlZddlmZmZmZddlm	Z
eje��Z
Gd�d��ZGd�d��ZGd�d	��ZGd
�de��ZGd�d
e��ZGd�d��ZGd�d��ZdS)�N)�ensure_bytes�ensure_unicode�urlparse)�
EXCEPTION_MAPc�(�eZdZgd�Zd�Zd�Zd�ZdS)�Monitor)zbefore-parameter-buildzrequest-createdzresponse-receivedz
after-callzafter-call-errorc�"�||_||_dS)z�Abstraction for monitoring clients API calls

        :param adapter: An adapter that takes event emitter events
            and produces monitor events

        :param publisher: A publisher for generated monitor events
        N)�_adapter�
_publisher)�self�adapter�	publishers   �F/opt/alt/python311/lib/python3.11/site-packages/botocore/monitoring.py�__init__zMonitor.__init__!s�� ��
�#�����c�P�|jD]}|�||j���dS)z(Register an event emitter to the monitorN)�_EVENTS_TO_REGISTER�
register_last�capture)r�
event_emitter�event_to_registers   r�registerzMonitor.register,s?��!%�!9�	I�	I���'�'�(9�4�<�H�H�H�H�	I�	Irc���	|j�||��}|r|j�|��dSdS#t$r)}t
�d||d���Yd}~dSd}~wwxYw)z�Captures an incoming event from the event emitter

        It will feed an event emitter event to the monitor's adaptor to create
        a monitor event and then publish that event to the monitor's publisher.
        z:Exception %s raised by client monitor in handling event %sT)�exc_infoN)r
�feedr�publish�	Exception�logger�debug)r�
event_name�payload�
monitor_event�es     rrzMonitor.capture1s���
	� �M�.�.�z�7�C�C�M��
7���'�'�
�6�6�6�6�6�
7�
7���	�	�	��L�L�L����	
�
�
�
�
�
�
�
�
�
�����	���s�7=�
A0�A+�+A0N)�__name__�
__module__�__qualname__rrrr�rrrrsV����������	$�	$�	$�I�I�I�
����rrc�d�eZdZejfd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
S)�MonitorEventAdapterc��||_dS)z�Adapts event emitter events to produce monitor events

        :type time: callable
        :param time: A callable that produces the current time
        N)�_time)r�times  rrzMonitorEventAdapter.__init__Es����
�
�
rc�8�|�|��di|��S)a�Feed an event emitter event to generate a monitor event

        :type emitter_event_name: str
        :param emitter_event_name: The name of the event emitted

        :type emitter_payload: dict
        :param emitter_payload: The payload to associated to the event
            emitted

        :rtype: BaseMonitorEvent
        :returns: A monitor event based on the event emitter events
            fired
        r')�_get_handler)r�emitter_event_name�emitter_payloads   rrzMonitorEventAdapter.feedMs)��5�t� � �!3�4�4�G�G��G�G�Grc��t|d|�d��d�dd��z��S)N�_handle_�.r�-�_)�getattr�split�replace)rr s  rr.z MonitorEventAdapter._get_handler]sA����*�z�/�/��4�4�Q�7�?�?��S�I�I�I�
�
�	
rc�r�t|jj|j|������|d<dS)N��service�	operation�	timestamp�current_api_call_event)�APICallEvent�
service_model�
service_id�	wire_name�_get_current_time)r�model�context�kwargss    r�_handle_before_parameter_buildz2MonitorEventAdapter._handle_before_parameter_buildbs?��,8��'�2��o��,�,�.�.�-
�-
�-
��(�)�)�)rc��|j}|d�|������}|j|_|j|_||d<dS)Nr>)r=�current_api_call_attempt_event)rE�new_api_call_attemptrC�headers�request_headers�url)r�requestrFrE�new_attempt_events     r�_handle_request_createdz+MonitorEventAdapter._handle_request_createdis_���/��#�$�
�
�
��)?�)?�)A�)A�
�
B�
B�	�-4�O��)� '����4E��0�1�1�1rc��|�d��}|�|��|_|�A|dd|_|dd|_|�d��|_n||_|S)NrI�ResponseMetadata�HTTPStatusCode�HTTPHeaders�Error)�pop�_get_latency�latency�http_status_code�response_headers�get�parsed_error�wire_exception)r�parsed_responserE�	exceptionrF�
attempt_events      r�_handle_response_receivedz-MonitorEventAdapter._handle_response_receivedrs��� ���$D�E�E�
� $� 1� 1�-� @� @�
���&�-<�"�.��. �M�*�.=�"�.��.�M�*�*9�)<�)<�W�)E�)E�M�&�&�+4�M�(��rc�z�|d�dd��|d_|�|��S)NrR�MaxAttemptsReachedFr>)r[�retries_exceeded�_complete_api_call)rrE�parsedrFs    r�_handle_after_callz&MonitorEventAdapter._handle_after_call�sA��=C��>
�

�#�"�E�
*�
*�	�(�)�:��&�&�w�/�/�/rc�l�|�|��|d_|�|��S�Nr>)�_is_retryable_exceptionrdre)rrEr_rFs    r�_handle_after_call_errorz,MonitorEventAdapter._handle_after_call_error�s9��"�9�9�)�D�D�	�$�	
�
��&�&�w�/�/�/rc�R�t|ttd����S)N�GENERAL_CONNECTION_ERROR)�
isinstance�tuple�RETRYABLE_EXCEPTIONS)rr_s  rrjz+MonitorEventAdapter._is_retryable_exception�s(����u�1�2L�M�N�N�
�
�	
rc�d�|�d��}|�|��|_|Sri)rVrWrX)rrE�
call_events   rrez&MonitorEventAdapter._complete_api_call�s0���[�[�!9�:�:�
�!�.�.�z�:�:�
���rc�:�|���|jz
S�N)rCr=�r�events  rrWz MonitorEventAdapter._get_latency�s���%�%�'�'�%�/�9�9rc�J�t|���dz��S)Ni�)�intr+�rs rrCz%MonitorEventAdapter._get_current_time�s���4�:�:�<�<�$�&�'�'�'rN)r$r%r&r,rrr.rGrPrargrkrjrerWrCr'rrr)r)Ds������� �I�����H�H�H� 
�
�
�

�
�
�F�F�F����"0�0�0�0�0�0�
�
�
�
���
:�:�:�(�(�(�(�(rr)c� �eZdZd�Zd�Zd�ZdS)�BaseMonitorEventc�0�||_||_||_dS)a�Base monitor event

        :type service: str
        :param service: A string identifying the service associated to
            the event

        :type operation: str
        :param operation: A string identifying the operation of service
            associated to the event

        :type timestamp: int
        :param timestamp: Epoch time in milliseconds from when the event began
        Nr:)rr;r<r=s    rrzBaseMonitorEvent.__init__�s�����"���"����rc�0�|jj�d|j�d�S)N�(�))�	__class__r$�__dict__rys r�__repr__zBaseMonitorEvent.__repr__�s ���.�)�>�>�D�M�>�>�>�>rc�P�t||j��r|j|jkSdS)NF)rnr�r�)r�others  r�__eq__zBaseMonitorEvent.__eq__�s*���e�T�^�,�,�	3��=�E�N�2�2��urN)r$r%r&rr�r�r'rrr{r{�sA������#�#�#�$?�?�?�����rr{c�,��eZdZ			d�fd�	Zd�Z�xZS)r?NFc���t���|||���||_||_|�g|_||_dS)a�Monitor event for a single API call

        This event corresponds to a single client method call, which includes
        every HTTP requests attempt made in order to complete the client call

        :type service: str
        :param service: A string identifying the service associated to
            the event

        :type operation: str
        :param operation: A string identifying the operation of service
            associated to the event

        :type timestamp: int
        :param timestamp: Epoch time in milliseconds from when the event began

        :type latency: int
        :param latency: The time in milliseconds to complete the client call

        :type attempts: list
        :param attempts: The list of APICallAttempts associated to the
            APICall

        :type retries_exceeded: bool
        :param retries_exceeded: True if API call exceeded retries. False
            otherwise
        r:N)�superrrX�attemptsrd)rr;r<r=rXr�rdr�s       �rrzAPICallEvent.__init__�sY���H	������y�I�	�	
�	
�	
���� ��
����D�M� 0����rc�r�t|j|j|���}|j�|��|S)z�Instantiates APICallAttemptEvent associated to the APICallEvent

        :type timestamp: int
        :param timestamp: Epoch time in milliseconds to associate to the
            APICallAttemptEvent
        r:)�APICallAttemptEventr;r<r��append)rr=r`s   rrJz!APICallEvent.new_api_call_attempt�sA��,��L�D�N�i�
�
�
�
�	
�
���]�+�+�+��r)NNF)r$r%r&rrJ�
__classcell__�r�s@rr?r?�sX����������+1�+1�+1�+1�+1�+1�Z������rr?c�.��eZdZ							d�fd�	Z�xZS)r�Nc���t���|||���||_||_||_||_||_|	|_|
|_dS)a�Monitor event for a single API call attempt

        This event corresponds to a single HTTP request attempt in completing
        the entire client method call.

        :type service: str
        :param service: A string identifying the service associated to
            the event

        :type operation: str
        :param operation: A string identifying the operation of service
            associated to the event

        :type timestamp: int
        :param timestamp: Epoch time in milliseconds from when the HTTP request
            started

        :type latency: int
        :param latency: The time in milliseconds to complete the HTTP request
            whether it succeeded or failed

        :type url: str
        :param url: The URL the attempt was sent to

        :type http_status_code: int
        :param http_status_code: The HTTP status code of the HTTP response
            if there was a response

        :type request_headers: dict
        :param request_headers: The HTTP headers sent in making the HTTP
            request

        :type response_headers: dict
        :param response_headers: The HTTP headers returned in the HTTP response
            if there was a response

        :type parsed_error: dict
        :param parsed_error: The error parsed if the service returned an
            error back

        :type wire_exception: Exception
        :param wire_exception: The exception raised in sending the HTTP
            request (i.e. ConnectionError)
        r:N)	r�rrXrMrYrLrZr\r])rr;r<r=rXrMrYrLrZr\r]r�s           �rrzAPICallAttemptEvent.__init__�sl���r	������y�I�	�	
�	
�	
������� 0���.��� 0���(���,����r)NNNNNNN)r$r%r&rr�r�s@rr�r��s^��������������B-�B-�B-�B-�B-�B-�B-�B-�B-�B-rr�c��eZdZdZdZdZdZdZdddd�Ze	j
d	��e	j
d
��d�Zgd�Zd
�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd �Z d!�Z!d"�Z"d#�Z#d$�Z$d%�Z%d&S)'�
CSMSerializer���i�XAmznRequestId�
XAmzRequestId�XAmzId2)zx-amzn-requestidzx-amz-request-idz
x-amz-id-2zSAWS4-HMAC-SHA256 Credential=(?P<access_key>\w+)/\d+/(?P<signing_region>[a-z0-9-]+)/zAWS (?P<access_key>\w+):)�v4�s3)r;r<r=r�rXrdrMrLrYrZr\r]c�>�|�|��||_dS)z�Serializes monitor events to CSM (Client Side Monitoring) format

        :type csm_client_id: str
        :param csm_client_id: The application identifier to associate
            to the serialized events
        N)�_validate_client_id�
csm_client_id�rr�s  rrzCSMSerializer.__init__ds&��	
� � ��/�/�/�*����rc�l�t|��|jkrtd|�d|j�d����dS)Nz&The value provided for csm_client_id: z exceeds the maximum length of z characters)�len�_MAX_CLIENT_ID_LENGTH�
ValueErrorr�s  rr�z!CSMSerializer._validate_client_idns^���}���� :�:�:��Q��Q�Q�)-�)C�Q�Q�Q���
�;�:rc��|�|��}|�|��}||d<|jD]4}t||d��}|�t|d|z��|||����5t	tj|d�����S)z�Serializes a monitor event to the CSM format

        :type event: BaseMonitorEvent
        :param event: The event to serialize to bytes

        :rtype: bytes
        :returns: The CSM serialized form of the event
        �TypeN�_serialize_)�
event_type)�,�:)�
separators)�_get_base_event_dict�_get_event_type�_SERIALIZEABLE_EVENT_PROPERTIESr6r�json�dumps)rrv�
event_dictr��attr�values      r�	serializezCSMSerializer.serializeus����.�.�u�5�5�
��)�)�%�0�0�
�'�
�6���8�	�	�D��E�4��.�.�E�� �3���m�d�2�3�3��:�*�������D�J�z�j�I�I�I�J�J�Jrc��d|jd�S)N�)�Version�ClientId)r�rus  rr�z"CSMSerializer._get_base_event_dict�s����*�
�
�	
rc��||d<dS)N�Servicer')rr;r�rFs    r�_serialize_servicez CSMSerializer._serialize_service�s�� '�
�9���rc��||d<dS)N�Apir')rr<r�rFs    r�_serialize_operationz"CSMSerializer._serialize_operation�s��%�
�5���rc��||d<dS)N�	Timestampr')rr=r�rFs    r�_serialize_timestampz"CSMSerializer._serialize_timestamp�s��"+�
�;���rc�j�t|��|d<|r|�||d��dSdS)N�AttemptCount���)r��_add_fields_from_last_attempt)rr�r�rFs    r�_serialize_attemptsz!CSMSerializer._serialize_attempts�sG��%(��]�]�
�>�"��	I��.�.�z�8�B�<�H�H�H�H�H�	I�	Irc�B�|jr>|�|j��}|�||d<|�|j��|d<|j�
|j|d<|j�|�|j|d��|j�|�|j|d��dSdS)N�Region�	UserAgent�FinalHttpStatusCode�ApiCall)rL�_get_region�_get_user_agentrYr\�_serialize_parsed_errorr]�_serialize_wire_exception)rr��last_attempt�regions    rr�z+CSMSerializer._add_fields_from_last_attempt�s����'�	��%�%�l�&B�C�C�F��!�'-�
�8�$�&*�&:�&:��,�'�'�J�{�#��(�4�0<�0M�J�,�-��$�0��(�(��)�:�y�
�
�
��&�2��*�*��+�Z��
�
�
�
�
�3�2rc�:�|dkr||d<dS|dkr||d<dSdS)Nr��Latency�ApiCallAttempt�AttemptLatencyr')rrXr�r�s    r�_serialize_latencyz CSMSerializer._serialize_latency�sB����"�"�$+�J�y�!�!�!�
�+�
+�
+�+2�J�'�(�(�(�,�
+rc��|rdnd|d<dS)Nr�r�MaxRetriesExceededr')rrdr�rFs    r�_serialize_retries_exceededz)CSMSerializer._serialize_retries_exceeded�s��1A�+G�1�1�a�
�'�(�(�(rc�4�t|��j|d<dS)N�Fqdn)r�netloc)rrMr�rFs    r�_serialize_urlzCSMSerializer._serialize_url�s��%�c�]�]�1�
�6���rc���|�|��|d<|�|��r|�|��|d<|�|��}|�||d<d|vr
|d|d<dSdS)Nr��	AccessKeyr�zX-Amz-Security-Token�SessionToken)r��
_is_signed�_get_access_keyr�)rrLr�rFr�s     r�_serialize_request_headersz(CSMSerializer._serialize_request_headers�s���#'�"6�"6��"G�"G�
�;���?�?�?�+�+�	L�&*�&:�&:�?�&K�&K�J�{�#��!�!�/�2�2����#)�J�x� �!�_�4�4�)8�&�*�J�~�&�&�&�5�4rc��||d<dS)N�HttpStatusCoder')rrYr�rFs    r�_serialize_http_status_codez)CSMSerializer._serialize_http_status_code�s��(8�
�#�$�$�$rc�b�|j���D]\}}||vr||||<�dSrt)�"_RESPONSE_HEADERS_TO_EVENT_ENTRIES�items)rrZr�rF�header�entrys      r�_serialize_response_headersz)CSMSerializer._serialize_response_headers�sL��"�D�J�J�L�L�	=�	=�M�F�E��)�)�)�$4�V�$<�
�5�!��	=�	=rc��|dkrdnd}|�|d|j��||dz<|�|d|j��||dz<dS)Nr��Final��Code�AwsException�Message�AwsExceptionMessage)�	_truncate�_MAX_ERROR_CODE_LENGTH�_MAX_MESSAGE_LENGTH)rr\r�r�rF�field_prefixs      rr�z%CSMSerializer._serialize_parsed_error�su��#-�	�"9�"9�w�w�r��48�N�N��� �$�"=�5
�5
�
�<�.�0�1�<@�>�>���#�T�%=�<
�<
�
�<�"7�7�8�8�8rc���|dkrdnd}|�|jj|j��||dz<|�t	|��|j��||dz<dS)Nr�r�r��SdkException�SdkExceptionMessage)r�r�r$�_MAX_EXCEPTION_CLASS_LENGTH�strr�)rr]r�r�rFr�s      rr�z'CSMSerializer._serialize_wire_exception�sy��#-�	�"9�"9�w�w�r��48�N�N��$�-�t�/O�5
�5
�
�<�.�0�1�<@�>�>������!9�<
�<
�
�<�"7�7�8�8�8rc�b�t|t��rdSt|t��rdSdS)Nr�r�)rnr?r�rus  rr�zCSMSerializer._get_event_type�s<���e�\�*�*�	$��9�
��2�
3�
3�	$�#�#�	$�	$rc��|�|��}|�|��\}}|�d��S)N�
access_key)�_get_auth_value�_get_auth_match�group)rrL�auth_valr5�
auth_matchs     rr�zCSMSerializer._get_access_key�s@���'�'��8�8���,�,�X�6�6�
��:�����-�-�-rc���|�|��sdS|�|��}|�|��\}}|dkrdS|�d��S)Nr��signing_region)r�r�r�r)rrLr�signature_versionrs     rr�zCSMSerializer._get_region�sl������/�/�	��4��'�'��8�8��(,�(<�(<�X�(F�(F�%��:���$�$��4���� 0�1�1�1rc�z�|�t|�dd����|j��S)Nz
User-Agentr�)r�rr[�_MAX_USER_AGENT_LENGTH�rrLs  rr�zCSMSerializer._get_user_agents9���~�~��?�.�.�|�R�@�@�A�A��'�
�
�	
rc�
�d|vS�N�
Authorizationr'rs  rr�zCSMSerializer._is_signed
s
���/�1�1rc�,�t|d��Sr
)rrs  rr�zCSMSerializer._get_auth_value
s���o�o�>�?�?�?rc�~�|j���D]"\}}|�|��}|r||fcS�#dS)N)NN)�_AUTH_REGEXSr��match)rrr�regexrs     rr�zCSMSerializer._get_auth_matchsZ��(,�(9�(?�(?�(A�(A�	0�	0�$��u��K�K��)�)�E��
0�(�%�/�/�/�/�
0��zrc�x�t|��|kr&t�d||��|d|�S|S)Nz6Truncating following value to maximum length of %s: %s)r�rr)r�text�
max_lengths   rr�zCSMSerializer._truncatesH���t�9�9�z�!�!��L�L�K���
�
�
�
����$�$��rN)&r$r%r&r�r�r�rr�r��re�compilerr�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r'rrr�r�Bs��������"%�� �� ����,�+��*�*�&��b�j�
/�
�
�
�b�j�4�5�5�
��L�
'�
'�
'�#�+�+�+����K�K�K�(
�
�
�(�(�(�&�&�&�,�,�,�I�I�I�
���*3�3�3�H�H�H�
2�2�2����8�8�8�
=�=�=�	
�	
�	
�	
�	
�	
�$�$�$�.�.�.�
2�2�2�
�
�
�2�2�2�@�@�@��������rr�c��eZdZdZd�Zd�ZdS)�SocketPublisheri c�4�||_||f|_||_dS)a)Publishes monitor events to a socket

        :type socket: socket.socket
        :param socket: The socket object to use to publish events

        :type host: string
        :param host: The host to send events to

        :type port: integer
        :param port: The port on the host to send events to

        :param serializer: The serializer to use to serialize the event
            to a form that can be published to the socket. This must
            have a `serialize()` method that accepts a monitor event
            and return bytes
        N)�_socket�_address�_serializer)r�socket�host�port�
serializers     rrzSocketPublisher.__init__%s$��"����t���
�%����rc�
�|j�|��}t|��|jkr0t�dt|��|j��dS|j�||j��dS)z�Publishes a specified monitor event

        :type event: BaseMonitorEvent
        :param event: The monitor event to be sent
            over the publisher's socket to the desired address.
        z`Serialized event of size %s exceeds the maximum length allowed: %s. Not sending event to socket.N)	rr�r��_MAX_MONITOR_EVENT_LENGTHrrr�sendtor)rrv�serialized_events   rrzSocketPublisher.publish:s��� �+�5�5�e�<�<���� � �4�#A�A�A��L�L�<��$�%�%��.�	
�
�
�
�F�����,�d�m�<�<�<�<�<rN)r$r%r&r!rrr'rrrr"s8������ (��&�&�&�*=�=�=�=�=rr)r��loggingrr,�botocore.compatrrr�botocore.retryhandlerrrp�	getLoggerr$rrr)r{r?r�r�rr'rr�<module>r(s�����������	�	�	�	�����B�B�B�B�B�B�B�B�B�B�G�G�G�G�G�G�	��	�8�	$�	$��)�)�)�)�)�)�)�)�X](�](�](�](�](�](�](�](�@��������89�9�9�9�9�#�9�9�9�xC-�C-�C-�C-�C-�*�C-�C-�C-�L]�]�]�]�]�]�]�]�@(=�(=�(=�(=�(=�(=�(=�(=�(=�(=r