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)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 4 Sep 2019 15:58:21 +0000 (11:58 -0400)
commit94e72386dd8c0269f889ab41eb68c34bef8e60c2
treece7f2e610a300f65ba49b7ab74902ad1f61631a5
parente186f62964847ca881a24bd68a3aa72277b28e6d
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.032168 seconds and 4 git commands to generate.