PHP 8.2.31
Preview: gc_collector.py Size: 1.42 KB
//proc/self/root/proc/self/root/opt/cloudlinux/venv/lib/python3.11/site-packages/prometheus_client/gc_collector.py

from __future__ import unicode_literals

import gc
import platform

from .metrics_core import CounterMetricFamily
from .registry import REGISTRY


class GCCollector(object):
    """Collector for Garbage collection statistics."""

    def __init__(self, registry=REGISTRY):
        if not hasattr(gc, 'get_stats') or platform.python_implementation() != 'CPython':
            return
        registry.register(self)

    def collect(self):
        collected = CounterMetricFamily(
            'python_gc_objects_collected',
            'Objects collected during gc',
            labels=['generation'],
        )
        uncollectable = CounterMetricFamily(
            'python_gc_objects_uncollectable',
            'Uncollectable object found during GC',
            labels=['generation'],
        )

        collections = CounterMetricFamily(
            'python_gc_collections',
            'Number of times this generation was collected',
            labels=['generation'],
        )

        for generation, stat in enumerate(gc.get_stats()):
            generation = str(generation)
            collected.add_metric([generation], value=stat['collected'])
            uncollectable.add_metric([generation], value=stat['uncollectable'])
            collections.add_metric([generation], value=stat['collections'])

        return [collected, uncollectable, collections]


GC_COLLECTOR = GCCollector()
"""Default GCCollector in default Registry REGISTRY."""

Directory Contents

Dirs: 4 × Files: 18

Name Size Perms Modified Actions
bridge DIR
- drwxr-xr-x 2026-02-05 08:01:15
Edit Download
- drwxr-xr-x 2026-02-05 08:01:15
Edit Download
twisted DIR
- drwxr-xr-x 2026-02-05 08:01:15
Edit Download
- drwxr-xr-x 2026-02-05 08:01:15
Edit Download
1.16 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
1.65 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
895 B lrw-r--r-- 2026-01-20 13:01:47
Edit Download
15.43 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
14.92 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
1.42 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
21.66 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
11.60 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
5.14 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
6.32 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
7.09 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
1.69 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
3.57 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
5.23 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
1.33 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
621 B lrw-r--r-- 2026-01-20 13:01:47
Edit Download
3.75 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
1.77 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).