HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //proc/1233/root/usr/lib/python3/dist-packages/compose/metrics/decorator.py
import functools

from compose.metrics.client import MetricsCommand
from compose.metrics.client import Status


class metrics:
    def __init__(self, command_name=None):
        self.command_name = command_name

    def __call__(self, fn):
        @functools.wraps(fn,
                         assigned=functools.WRAPPER_ASSIGNMENTS,
                         updated=functools.WRAPPER_UPDATES)
        def wrapper(*args, **kwargs):
            if not self.command_name:
                self.command_name = fn.__name__
            result = fn(*args, **kwargs)
            MetricsCommand(self.command_name, status=Status.SUCCESS).send_metrics()
            return result
        return wrapper