ncs.progress Module
MAAPI progress trace high level module.
This module defines a high level interface to the low-level maapi functions.
In the Progress Trace a span is used to meassure duration of an event, the 'start' and 'stop' messages in the progress trace log:
start,2023-08-28T10:42:51.249865,,,,45,306,running,cli,,"foobar"... ... stop,2023-08-28T10:42:51.284359,0.034494,,,45,306,running,cli,,"foobar"...
maapi.Transaction.start_progress_span() and maapi.Maapi.start_progress_span() return progress.Span objects, which contains the span_id and trace_id (if enabled) attributes. Once the object is deleted/exited or manually obj.end() is called the stop message is written to the progress trace.
Inside a span multiple sub spans can be created, sp2 in the below example.
import ncs
m = ncs.maapi.Maapi()
m.start_user_session('admin', my context')
t = m.start_read_trans()
sp1 = t.start_progress_span('first span')
t.progress_info('info message')
sp2 = t.start_progress_span('second span')
sp2.end()
sp1.end()Another way is to use context managers, which will handle all cleanup related to transactions, user sessions and socket connections:
with ncs.maapi.Maapi() as m:
m.start_user_session('admin', my context')
with m.start_read_trans() as t:
with t.start_progress_span('first span'):
t.progress_info('info message')
with t.start_progress_span('second span'):
passFinally, a really compact way of doing this:
There are multiple optional fields.
Functions
conv_links
convert from [Span() | dict()] -> [dict()]
Classes
class EmptySpan
Members:
class Span
Members:
Last updated
Was this helpful?

