Add ellapsed time to REST response logs

Change-Id: I01f752b8f00e0e38a38a3799232f3bef5ca5dd97
This commit is contained in:
Adit Sarfaty 2017-06-04 14:32:16 +03:00
parent 373506a8d4
commit 571fa95406

View File

@ -16,6 +16,7 @@
import re import re
import requests import requests
import six.moves.urllib.parse as urlparse import six.moves.urllib.parse as urlparse
import time
from oslo_log import log from oslo_log import log
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
@ -183,15 +184,18 @@ class RESTClient(object):
method, request_url, request_headers, method, request_url, request_headers,
self._mask_password(body)) self._mask_password(body))
ts = time.time()
result = do_request( result = do_request(
request_url, request_url,
data=body, data=body,
headers=request_headers) headers=request_headers)
te = time.time()
if not silent: if not silent:
LOG.debug("REST call: %s %s. Response: %s", LOG.debug("REST call: %s %s. Response: %s. Took %2.4f",
method, request_url, result.json() method, request_url,
if result.content else '') result.json() if result.content else '',
te - ts)
self._validate_result( self._validate_result(
result, RESTClient._VERB_RESP_CODES[method.lower()], result, RESTClient._VERB_RESP_CODES[method.lower()],