Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: Simon Marchi via lttng-dev <lttng-dev@lists.lttng.org>
To: Maksim Khmelevskiy <mk.void.mail@gmail.com>, lttng-dev@lists.lttng.org
Subject: Re: [lttng-dev] C API message iterator example for libbabeltrace2
Date: Fri, 19 Aug 2022 11:00:19 -0400	[thread overview]
Message-ID: <87a1bad5-9942-3d6a-9726-1e4e74bea4d2@simark.ca> (raw)
In-Reply-To: <CACXehJBBkAm-7U2fwOd-qaGE5OgbsAZEci5v57XkmUp=7vtKNA@mail.gmail.com>

On 8/12/22 09:19, Maksim Khmelevskiy via lttng-dev wrote:
> Hi,
>

> there is a nice py message iterator example
> <https://babeltrace.org/docs/v2.0/python/bt2/examples.html> but for C
> API only plugins are covered with examples, do you think it would make
> sense to create an example of a standalone application which simply
> uses `source.ctf.fs` as source and iterates over all messages? It
> would be nice hint for those who want to see an example of graph
> creation with all the code in one file.

Hi Maksim,

I'm not sure which example you are referring to exactly.  But in Python,
we have the high-level TraceCollectionMessageIterator object, which does
roughly:

 - Instantiate source and filter components according to the provided
   specs, including automatic source discovery
 - Instantiate a flt.utils.muxer component to merge the streams from all
   sources ports
 - Instantiate a sink component that presents the events as a Python
   iterable
 - Connect the ports of all these components
 - More things that are irrelevant here

There is no such high-level object in the C interface, so you have
to do all this by hand, it will necessarily be much more verbose.  It
would be nice to have the equivalent of TraceCollectionMessageIterator
in the C API, it is just not done yet due to lack of resources.

I did search in the documentation for an example program that uses the C
API to create and run a graph, and I haven't found one.  I agree that
adding one would be nice.  I'll look into writing one.

Regarding your use case:

> I'm interested in that example because I want to transform CTF file
> into list of C structures representing messages.

I have some questions:

 - Is the data you want to convert found in the metadata of the traces
   (description of event types) of in the payload of events?
 - Why do you want to write this in C instead of Python?  It sounds like
   it would be much faster to write in Python (with
   TraceCollectionMessageIterator), and it doesn't sound like something
   where the performance is critical (but of course I don't have the
   full context).
 - Why do you need to write an application where you create and run the
   graph yourself?  Could you instead just write your sink component
   class (which reads the messages and writes your output files),
   packaged in a plugin and use it through the babeltrace2 command-line:

     $ babeltrace2 /path/to/ctf/trace -c sink.foo.bar -p 'output="out.h"'

   ?  This way, you just have to care about writing your component
   class, which does the conversion you need.

Simon
_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

  reply	other threads:[~2022-08-19 15:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-12 13:19 Maksim Khmelevskiy via lttng-dev
2022-08-19 15:00 ` Simon Marchi via lttng-dev [this message]
2022-08-20 16:14   ` Maksim Khmelevskiy via lttng-dev
2022-08-24 15:56     ` Simon Marchi via lttng-dev

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=87a1bad5-9942-3d6a-9726-1e4e74bea4d2@simark.ca \
    --to=lttng-dev@lists.lttng.org \
    --cc=mk.void.mail@gmail.com \
    --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