o
    i                     @   s<   d dl mZ d dlmZ d dlmZmZ G dd deZdS )    )defaultdict)api)report_errorsreport_warningsc                   @   s$   e Zd Zedd Zedd ZdS )MetricClientc                 C   s   |j ddd}|jddd}d|_|j dd	d}|jd
dd |jddtd |jdddd |jdddd |jddd d |jddd d |jdddd |jddd d |j| jd d S ) NmetriczPost metrics.)helpVerbsverb)titledestTpostzPost metricsnamezmetric namevaluez'metric value (integer or decimal value))r   typez--hostzFscopes your metric to a specific host (default to the local host name) )r   defaultz	--no_hostz9no host is associated with the metric (overrides --host))
store_true)r   actionz--devicez'scopes your metric to a specific devicez--tagszcomma-separated list of tagsz--localhostnamezddeprecated, used to force `--host` to the local hostname (now default when no `--host` is specified)z--typezAtype of the metric - gauge(32bit float) or counter(64bit integer))func)
add_parseradd_subparsersrequiredadd_argumentfloatset_defaults_post)cls
subparsersparserverb_parserspost_parser r"   K/home/ubuntu/.local/lib/python3.10/site-packages/datadog/dogshell/metric.pysetup_parser   s.   zMetricClient.setup_parserc                 C   s   |j t_|jr	dn|j}|jrttdd |jdD }nd}tj	j
|j|j||j||jd}tt|}|jr@|d d t| t| dS )z 
        Post a metric.
        Nc                 S   s   g | ]}|r|  qS r"   )strip).0tr"   r"   r#   
<listcomp>5   s    z&MetricClient._post.<locals>.<listcomp>,)r   pointshostdevicetagsmetric_typewarningsz`--localhostname` command line flag is deprecated, made default when no `--host` is specified. See the `--host` option for more information.)timeoutr   _timeoutno_hostr+   r-   sortedsetsplitMetricsendr   r   r,   r   r   listlocalhostnameappendr   r   )r   argsr+   r-   resr"   r"   r#   r   *   s    
zMetricClient._postN)__name__
__module____qualname__classmethodr$   r   r"   r"   r"   r#   r      s
    
r   N)	collectionsr   datadogr   datadog.dogshell.commonr   r   objectr   r"   r"   r"   r#   <module>   s   