From c5b66b2ab887ede49f67b3a2944266af9f28b925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=88=90=E4=B9=89?= Date: Tue, 22 Nov 2022 10:09:48 +0800 Subject: [PATCH] add Timer decorator support partial function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴成义 --- prometheus_client/decorator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/prometheus_client/decorator.py b/prometheus_client/decorator.py index 1ad2c977..8f3cb879 100644 --- a/prometheus_client/decorator.py +++ b/prometheus_client/decorator.py @@ -34,6 +34,7 @@ from __future__ import print_function import collections +import functools import inspect import itertools import operator @@ -105,7 +106,7 @@ def __init__(self, func=None, name=None, signature=None, self.name = '_lambda_' self.doc = func.__doc__ self.module = func.__module__ - if inspect.isfunction(func): + if inspect.isfunction(func) or isinstance(func, functools.partial): argspec = getfullargspec(func) self.annotations = getattr(func, '__annotations__', {}) for a in ('args', 'varargs', 'varkw', 'defaults', 'kwonlyargs',