File: //opt/cppython/lib/python3.8/site-packages/botocore/__pycache__/monitoring.cpython-38.pyc
U
KD�guP � @ s� d dl Z d dlZd dlZd dlZd dlmZmZmZ d dlm Z
e�e�Z
G dd� d�ZG dd� d�ZG dd � d �ZG d
d� de�ZG dd
� d
e�ZG dd� d�ZG dd� d�ZdS )� N)�ensure_bytes�ensure_unicode�urlparse)�
EXCEPTION_MAPc @ s2 e Zd ZdddddgZdd� Zdd � Zd
d� ZdS )
�Monitorzbefore-parameter-buildzrequest-createdzresponse-receivedz
after-callzafter-call-errorc C s || _ || _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�adapterZ publisher� r �@/opt/cppython/lib/python3.8/site-packages/botocore/monitoring.py�__init__! s zMonitor.__init__c C s | j D ]}|�|| j� qdS )z(Register an event emitter to the monitorN)�_EVENTS_TO_REGISTERZ
register_last�capture)r Z
event_emitterZevent_to_registerr r r �register, s
zMonitor.registerc
K s\ z"| j �||�}|r | j�|� W n4 tk
rV } ztjd||dd� W 5 d}~X Y nX dS )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�payloadZ
monitor_event�er r r r 1 s �zMonitor.captureN)�__name__�
__module__�__qualname__r r
r r r r r r r s �r c @ sr e Zd Zejfdd�Zdd� Zdd� Zdd� Zd d
� Zdd� Z d
d� Z
dd� Zdd� Zdd� Z
dd� Zdd� ZdS )�MonitorEventAdapterc C s
|| _ 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 �timer r r r
E s zMonitorEventAdapter.__init__c C s | � |�f |�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
)�_get_handler)r Zemitter_event_nameZemitter_payloadr r r r M s zMonitorEventAdapter.feedc C s t | d|�d�d �dd� �S )NZ_handle_�.r �-�_)�getattr�split�replace)r r r r r r ] s �z MonitorEventAdapter._get_handlerc K s t |jj|j| �� d�|d<