diff --git a/tests/test_time_execution.py b/tests/test_time_execution.py index 4dff1a7..e5b05c1 100644 --- a/tests/test_time_execution.py +++ b/tests/test_time_execution.py @@ -125,3 +125,33 @@ def go(): for metric in self._query_influx(go.fqn): self.assertEqual(metric['exception_message'], 'test exception') + + def test_time_execution_with_func_args(self): + param = 'foo' + + def hook(response, exception, metric, func_args, func_kwargs): + self.assertEqual(func_args[0], param) + return metric + + configure(backends=[self.backend], hooks=[hook]) + + @time_execution + def go(param1): + return '200 OK' + + go(param) + + def test_time_execution_with_func_kwargs(self): + param = 'foo' + + def hook(response, exception, metric, func_args, func_kwargs): + self.assertEqual(func_kwargs['param1'], param) + return metric + + configure(backends=[self.backend], hooks=[hook]) + + @time_execution + def go(param1): + return '200 OK' + + go(param1=param) diff --git a/time_execution/time_execution.py b/time_execution/time_execution.py index e229278..72e730e 100755 --- a/time_execution/time_execution.py +++ b/time_execution/time_execution.py @@ -109,7 +109,9 @@ def __call__(self, *args, **kwargs): metadata = _apply_hooks( response=response, exception=exception, - metric=metric + metric=metric, + func_args=args, + func_kwargs=kwargs ) metric.update(metadata)