bt2: add auto source discovery support to TraceCollectionMessageIterator
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 5 Aug 2019 18:45:38 +0000 (14:45 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 12 Aug 2019 02:19:51 +0000 (22:19 -0400)
commitf3c9a159782f70dbd0e5dedb37e4a1ef8a6d304e
treec1d2cbece7784dd1d5949699815792f75adb047c
parenta83410cd12c9acfe79443782e7a5311a6dd6ca59
bt2: add auto source discovery support to TraceCollectionMessageIterator

This patch makes TraceCollectionMessageIterator capable of automatically
detecting source components from given input strings, similar to how the
command line interface does.

A new type AutoSourceComponentSpec is introduced.  The user can
instantiate this type, passing a mandatory input string (equivalent to a
non-option argument on the CLI).  The user can then pass instances of
AutoSourceComponentSpec in the source_component_specs list when creating
a TraceCollectionMessageIterator.  In
TraceCollectionMessageIterator.__init_, we run the automatic source
algorithm on all inputs passed through AutoSourceComponentSpec
objects.  We create ComponentSpec from the results of the auto discovery
and append them to the source component spec list.  The rest of the
TraceCollectionMessageIterator then works as before.

The user can attach params and log levels to AutoSourceComponentSpec
inputs.  The semantic for those is the same as for the CLI.  There is
also an `obj` parameter, allowing to pass an arbitrary Python object.
The semantic for this one is the same as the log level: if an
auto-discovered component comes from multiple inputs, it will receive
the obj of the last input that contributed to getting it instantiated
that has a non-None `obj`.

For convenience, some shorthands when creating a
TraceCollectionMessageIterator are equivalent to using an
AutoSourceComponentSpec.  For example, these three forms are equivalent:

 - TraceCollectionMessageIterator('foo')
 - TraceCollectionMessageIterator(AutoSourceComponentSpec('foo'))
 - TraceCollectionMessageIterator([AutoSourceComponentSpec('foo')])

Implementation details
----------------------

New test cases are added to test the new feature.  They are based on
the corresponding CLI tests, in that they test equivalent scenarios
(same inputs, expecting the same results).

In order for TraceCollectionMessageIterator to find the test plugin
(both bt_plugin_test.py files), the only way I found was to amend
BABELTRACE_PLUGIN_PATH for the duration of the test.

Change-Id: I0e1100d850c920723861609cfa14707f8c669892
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1826
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
src/bindings/python/bt2/Makefile.am
src/bindings/python/bt2/bt2/__init__.py
src/bindings/python/bt2/bt2/native_bt.i
src/bindings/python/bt2/bt2/native_bt_autodisc.i [new file with mode: 0644]
src/bindings/python/bt2/bt2/native_bt_autodisc.i.h [new file with mode: 0644]
src/bindings/python/bt2/bt2/trace_collection_message_iterator.py
src/bindings/python/bt2/setup.py.in
tests/bindings/python/bt2/test_package.py
tests/bindings/python/bt2/test_trace_collection_message_iterator.py
tests/data/auto-source-discovery/params-log-level/bt_plugin_test.py
tests/utils/utils.sh
This page took 0.026139 seconds and 4 git commands to generate.