SILENT KILLERPanel

Current Path: > > opt > cloudlinux > venv > lib64 > python3.11 > site-packages > prometheus_client


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: //opt/cloudlinux/venv/lib64/python3.11/site-packages/prometheus_client

NameTypeSizeLast ModifiedActions
__pycache__ Directory - -
bridge Directory - -
openmetrics Directory - -
twisted Directory - -
__init__.py File 1817 bytes April 17 2025 13:10:58.
asgi.py File 1185 bytes April 17 2025 13:10:58.
context_managers.py File 1691 bytes April 17 2025 13:10:58.
core.py File 895 bytes April 17 2025 13:10:58.
decorator.py File 15802 bytes April 17 2025 13:10:58.
exposition.py File 15283 bytes April 17 2025 13:10:58.
gc_collector.py File 1458 bytes April 17 2025 13:10:58.
metrics.py File 22184 bytes April 17 2025 13:10:58.
metrics_core.py File 11881 bytes April 17 2025 13:10:58.
mmap_dict.py File 5264 bytes April 17 2025 13:10:58.
multiprocess.py File 6474 bytes April 17 2025 13:10:58.
parser.py File 7256 bytes April 17 2025 13:10:58.
platform_collector.py File 1735 bytes April 17 2025 13:10:58.
process_collector.py File 3654 bytes April 17 2025 13:10:58.
registry.py File 5357 bytes April 17 2025 13:10:58.
samples.py File 1358 bytes April 17 2025 13:10:58.
utils.py File 621 bytes April 17 2025 13:10:58.
values.py File 3836 bytes April 17 2025 13:10:58.

Reading File: //opt/cloudlinux/venv/lib64/python3.11/site-packages/prometheus_client/context_managers.py

from __future__ import unicode_literals

from timeit import default_timer

from .decorator import decorate


class ExceptionCounter(object):
    def __init__(self, counter, exception):
        self._counter = counter
        self._exception = exception

    def __enter__(self):
        pass

    def __exit__(self, typ, value, traceback):
        if isinstance(value, self._exception):
            self._counter.inc()

    def __call__(self, f):
        def wrapped(func, *args, **kwargs):
            with self:
                return func(*args, **kwargs)

        return decorate(f, wrapped)


class InprogressTracker(object):
    def __init__(self, gauge):
        self._gauge = gauge

    def __enter__(self):
        self._gauge.inc()

    def __exit__(self, typ, value, traceback):
        self._gauge.dec()

    def __call__(self, f):
        def wrapped(func, *args, **kwargs):
            with self:
                return func(*args, **kwargs)

        return decorate(f, wrapped)


class Timer(object):
    def __init__(self, callback):
        self._callback = callback

    def _new_timer(self):
        return self.__class__(self._callback)

    def __enter__(self):
        self._start = default_timer()

    def __exit__(self, typ, value, traceback):
        # Time can go backwards.
        duration = max(default_timer() - self._start, 0)
        self._callback(duration)

    def __call__(self, f):
        def wrapped(func, *args, **kwargs):
            # Obtaining new instance of timer every time
            # ensures thread safety and reentrancy.
            with self._new_timer():
                return func(*args, **kwargs)

        return decorate(f, wrapped)

SILENT KILLER Tool