diff options
| author | Zuul <zuul@review.opendev.org> | 2023-02-13 18:53:56 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2023-02-13 18:53:56 +0000 |
| commit | 4655a239877b6a09e51cb2b7b0cba6985b294fe4 (patch) | |
| tree | 8a4f40357ecc1474834467380b54a73d42ddedc9 /cinderclient | |
| parent | c8eb9bd0a9e1826a8efd67e71205fb57e7fd155e (diff) | |
| parent | da5ecebb3353618542aa84c2078b03f1a9f6ad83 (diff) | |
| download | python-cinderclient-4655a239877b6a09e51cb2b7b0cba6985b294fe4.tar.gz | |
Merge "Add support for collect-timing option"
Diffstat (limited to 'cinderclient')
| -rw-r--r-- | cinderclient/shell.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cinderclient/shell.py b/cinderclient/shell.py index dc9190a..ad7876c 100644 --- a/cinderclient/shell.py +++ b/cinderclient/shell.py @@ -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, |
