Add support for collect-timing option
When we run "cinder help" we can see that there is a --collect-timing option: --collect-timing Collect per-API call timing information. This is a keystone session option that we are not currently acting on from a user perspective. This patch adds support for this option, and we'll be able to see the timing in a similar way as we do with OSC: $ cinder --collect-timing api-version +------+---------+---------+-------------+ | ID | Status | Version | Min_version | +------+---------+---------+-------------+ | v3.0 | CURRENT | 3.66 | 3.0 | +------+---------+---------+-------------+ +--------+------------------------------------------------+----------+ | method | url | seconds | +--------+------------------------------------------------+----------+ | GET | http://192.168.121.243/identity | 0.003591 | | POST | http://192.168.121.243/identity/v3/auth/tokens | 0.016649 | | GET | http://192.168.121.243/volume/ | 0.004012 | | GET | http://192.168.121.243/volume/ | 0.004543 | +--------+------------------------------------------------+----------+ The patch formats the "elapsed" time attribute into seconds and renames the column to "seconds" to make it more user friendly similar to OSC. If we didn't it would look like 0:00:00.003744 Closes-Bug: #1960337 Change-Id: Ia6b31794bf60a351007cc4476a76b9bcb76bf378
This commit is contained in:
parent
6afd886cdd
commit
da5ecebb33
@ -705,6 +705,12 @@ class OpenStackCinderShell(object):
|
||||
if not auth_session:
|
||||
auth_session = self._get_keystone_session()
|
||||
|
||||
# collect_timing is a keystone session option
|
||||
if (not isinstance(auth_session, session.Session)
|
||||
and getattr(args, 'collect_timing', False) is True):
|
||||
raise exc.AuthorizationFailure("Provided auth plugin doesn't "
|
||||
"support collect_timing option")
|
||||
|
||||
insecure = self.options.insecure
|
||||
|
||||
client_args = dict(
|
||||
@ -805,6 +811,17 @@ class OpenStackCinderShell(object):
|
||||
print("To display trace use next command:\n"
|
||||
"osprofiler trace show --html %s " % trace_id)
|
||||
|
||||
if getattr(args, 'collect_timing', False) is True:
|
||||
self._print_timings(auth_session)
|
||||
|
||||
def _print_timings(self, session):
|
||||
timings = session.get_timings()
|
||||
utils.print_list(
|
||||
timings,
|
||||
fields=('method', 'url', 'seconds'),
|
||||
sortby_index=None,
|
||||
formatters={'seconds': lambda r: r.elapsed.total_seconds()})
|
||||
|
||||
def _discover_client(self,
|
||||
current_client,
|
||||
os_api_version,
|
||||
|
6
releasenotes/notes/collect-timing-ce6d521d40d422fb.yaml
Normal file
6
releasenotes/notes/collect-timing-ce6d521d40d422fb.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
`Bug #1960337 <https://bugs.launchpad.net/cinder/+bug/1960337>`_: Added
|
||||
support for ``collect-timing`` parameter to see the timings of REST API
|
||||
requests from the client when using Keystone authentication.
|
Loading…
x
Reference in New Issue
Block a user