Merge "Add initial 'trace list' command"
This commit is contained in:
commit
22c1a99209
|
@ -15,7 +15,10 @@
|
|||
|
||||
import json
|
||||
import os
|
||||
import prettytable
|
||||
import six
|
||||
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from osprofiler.cmd import cliutils
|
||||
|
@ -150,3 +153,26 @@ class TraceCommands(BaseCommand):
|
|||
|
||||
_create_sub_graph(trace)
|
||||
return dot
|
||||
|
||||
@cliutils.arg("--connection-string", dest="conn_str",
|
||||
default=(cliutils.env("OSPROFILER_CONNECTION_STRING")),
|
||||
required=True,
|
||||
help="Storage driver's connection string. Defaults to "
|
||||
"env[OSPROFILER_CONNECTION_STRING] if set")
|
||||
def list(self, args):
|
||||
try:
|
||||
engine = base.get_driver(args.conn_str, **args.__dict__)
|
||||
except Exception as e:
|
||||
raise exc.CommandError(e.message)
|
||||
|
||||
fields = ("base_id", "timestamp")
|
||||
pretty_table = prettytable.PrettyTable(fields)
|
||||
pretty_table.align = "l"
|
||||
traces = engine.list_traces({}, fields)
|
||||
for trace in traces:
|
||||
row = [trace[field] for field in fields]
|
||||
pretty_table.add_row(row)
|
||||
if six.PY3:
|
||||
print(encodeutils.safe_encode(pretty_table.get_string()).decode())
|
||||
else:
|
||||
print(encodeutils.safe_encode(pretty_table.get_string()))
|
||||
|
|
|
@ -5,3 +5,4 @@ requests>=2.10.0 # Apache-2.0
|
|||
netaddr>=0.7.13,!=0.7.16 # BSD
|
||||
oslo.concurrency>=3.8.0 # Apache-2.0
|
||||
oslo.serialization>=2.18.0,!=2.19.1 # Apache-2.0
|
||||
PrettyTable>=0.7.1,<0.8 # BSD
|
||||
|
|
Loading…
Reference in New Issue