From 024b5af64b69a6fb9eab7c5764d8f2b91f17ec2f Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Tue, 18 Aug 2020 15:13:36 +0200 Subject: [PATCH] Log time of the apply_func only if it took more than 0.1 second It seems that logging start and end time of the neutron_lib.db.resource_extend.apply_func function is little bit too much for e.g. our gate as neutron-server logs are huge in such case. So lets use directly oslo_utils.timeutils.time_it() function and log end of such calls only if it will take more than 0.1 seconds. If function was executed in shorter time, it isn't really necessary to have it logged. Change-Id: I3931c4f7cac4df72d71403ebcaa6ec0b83756640 Closes-Bug: #1892017 --- neutron_lib/db/resource_extend.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/neutron_lib/db/resource_extend.py b/neutron_lib/db/resource_extend.py index 068cdaf37..f2ea2fc34 100644 --- a/neutron_lib/db/resource_extend.py +++ b/neutron_lib/db/resource_extend.py @@ -18,9 +18,15 @@ NOTE: This module shall not be used by external projects. It will be moved import collections import inspect +from oslo_log import log as logging +from oslo_utils import timeutils + from neutron_lib.utils import helpers +LOG = logging.getLogger(__name__) + + # This dictionary will store methods for extending API resources. # Extensions can add their own methods by invoking register_funcs(). _resource_extend_functions = { @@ -70,7 +76,7 @@ def get_funcs(resource): return _resource_extend_functions.get(resource, []) -@helpers.timecost +@timeutils.time_it(LOG, min_duration=0.1) def apply_funcs(resource_type, response, db_object): """Appy registered functions for the said resource type.