From 571fa9540622f0eb5bae59f8923c0ed0d9141900 Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Sun, 4 Jun 2017 14:32:16 +0300 Subject: [PATCH] Add ellapsed time to REST response logs Change-Id: I01f752b8f00e0e38a38a3799232f3bef5ca5dd97 --- vmware_nsxlib/v3/client.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/vmware_nsxlib/v3/client.py b/vmware_nsxlib/v3/client.py index 69122fa1..bc6e4bc0 100644 --- a/vmware_nsxlib/v3/client.py +++ b/vmware_nsxlib/v3/client.py @@ -16,6 +16,7 @@ import re import requests import six.moves.urllib.parse as urlparse +import time from oslo_log import log from oslo_serialization import jsonutils @@ -183,15 +184,18 @@ class RESTClient(object): method, request_url, request_headers, self._mask_password(body)) + ts = time.time() result = do_request( request_url, data=body, headers=request_headers) + te = time.time() if not silent: - LOG.debug("REST call: %s %s. Response: %s", - method, request_url, result.json() - if result.content else '') + LOG.debug("REST call: %s %s. Response: %s. Took %2.4f", + method, request_url, + result.json() if result.content else '', + te - ts) self._validate_result( result, RESTClient._VERB_RESP_CODES[method.lower()],