a
    ö£Beê  ã                   @   sZ   d dl Z d dlZd dlmZ ddlmZmZ ddlmZm	Z	m
Z
 G dd„ deƒZeƒ ZdS )é    N)ÚIterableé   )ÚCounterMetricFamilyÚMetric)Ú	CollectorÚCollectorRegistryÚREGISTRYc                   @   s4   e Zd ZdZefedœdd„Zee dœdd„Z	dS )	ÚGCCollectorz,Collector for Garbage collection statistics.)Úregistryc                 C   s(   t tdƒrt ¡ dkrd S | | ¡ d S )NÚ	get_statsÚCPython)ÚhasattrÚgcÚplatformÚpython_implementationÚregister)Úselfr
   © r   úa/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/prometheus_client/gc_collector.pyÚ__init__   s    zGCCollector.__init__)Úreturnc                 C   s”   t dddgd�}t dddgd�}t dddgd�}tt ¡ ƒD ]L\}}t|ƒ}|j|g|d	 d
� |j|g|d d
� |j|g|d d
� q<|||gS )NZpython_gc_objects_collectedzObjects collected during gcÚ
generation)ÚlabelsZpython_gc_objects_uncollectablez%Uncollectable objects found during GCZpython_gc_collectionsz-Number of times this generation was collectedÚ	collected)ÚvalueÚuncollectableÚcollections)r   Ú	enumerater   r   ÚstrZ
add_metric)r   r   r   r   ÚgenÚstatr   r   r   r   Úcollect   s*    ýýýzGCCollector.collectN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r!   r   r   r   r   r	   	   s   r	   )r   r   Útypingr   Zmetrics_corer   r   r
   r   r   r   r	   ZGC_COLLECTORr   r   r   r   Ú<module>   s   #