From: Rocky Dunlap via lttng-dev <lttng-dev@lists.lttng.org>
To: Simon Marchi <simark@simark.ca>
Cc: lttng-dev@lists.lttng.org
Subject: Re: bt2 python - accessing component instances added to graph
Date: Mon, 30 Mar 2020 14:41:00 -0600 [thread overview]
Message-ID: <CADtyBo7c1-Ge+BbRGPG669woGZPiCfy5pfqrMHDF=aPfUWmU2g@mail.gmail.com> (raw)
In-Reply-To: <32146698-0314-1eaf-e422-2c9e088056e7@simark.ca>
[-- Attachment #1.1: Type: text/plain, Size: 2166 bytes --]
(Adding the list back in - I meant to reply-all before...)
Simon,
Yes, the obj solution should work just fine - I was wondering about that
parameter and the approach makes sense to me. Thanks!
Rocky
On Mon, Mar 30, 2020 at 2:38 PM Simon Marchi <simark@simark.ca> wrote:
> On 2020-03-30 4:24 p.m., Rocky Dunlap wrote:
> > Simon,
> >
> > In my case, after the graph completes, I was trying to access the sink
> instances in order to collect some statistics collected inside the instance
> during the graph run. I guess then the question is how are the graph
> components supposed to communicate with the outside world in general, such
> as filling in some Python data structures with info from a trace for
> post-processing or further analysis in Python? Or is the expectation that
> sink components will retain no state at all after the graph completes?
> >
> > Rocky
>
> Hi Rocky,
>
> Was it your intention to not do a reply-all? I think this would be good
> info for all to read. If not,
> please do a reply-all and I'll replay again what I wrote below on the list.
>
> Of course the sinks are expected to produce some result outside of their
> own little internal state. For
> sinks that produce some trace files, they'll typically write on the
> filsystem (like sink.ctf.fs).
>
> But if you want to send some results to another Python object/data
> structure, the `obj` parameter of
> `add_component` is pretty much meant for that. You can pass in a
> reference to a Python object, and
> the component receives it in its `__init__`. We thought that this could
> be useful, for example, if
> the sink needs to receive a connection handle to a database, for example.
> That handle can be created
> outside of the sink and passed it when instantiating the component. Think
> of it like some void* user
> data in C.
>
> In your case, you could create whatever object you need to collect your
> statistics/results, and pass
> a reference to it.
>
> Here's an example in the tests:
>
>
> https://github.com/efficios/babeltrace/blob/8b305066676fc7aa433e8eb668f9de8802008025/tests/bindings/python/bt2/test_graph.py#L106-L120
>
> Does that help?
>
> Simon
>
[-- Attachment #1.2: Type: text/html, Size: 2808 bytes --]
[-- Attachment #2: Type: text/plain, Size: 156 bytes --]
_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
prev parent reply other threads:[~2020-03-30 20:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-30 5:24 bt2 python - accessing component instances added to graph Rocky Dunlap via lttng-dev
2020-03-30 13:45 ` Simon Marchi via lttng-dev
[not found] ` <CADtyBo6mzBQ3sVUpc4gbxEf7LVsfV+m8oWNMjMdG1gDPsnRR6A@mail.gmail.com>
[not found] ` <32146698-0314-1eaf-e422-2c9e088056e7@simark.ca>
2020-03-30 20:41 ` Rocky Dunlap via lttng-dev [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CADtyBo7c1-Ge+BbRGPG669woGZPiCfy5pfqrMHDF=aPfUWmU2g@mail.gmail.com' \
--to=lttng-dev@lists.lttng.org \
--cc=dunlap@ucar.edu \
--cc=simark@simark.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).