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
This commit is contained in:
Slawek Kaplonski
2020-08-18 15:13:36 +02:00
parent 96e1d028b8
commit 024b5af64b

View File

@@ -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.