Adding new events / streams to an existing trace?

Alec Rivers via lttng-dev <[email protected]> Mon, 21 Jul 2025 23:21:48 -0700
Newsgroups org.lttng.lists.lttng-dev
Message-ID <CAK49rV4DhdWJ8HeebmOhSMAj68anghiKMTKwxBWaSvtGcdW0bw@mail.gmail.com>
--000000000000a2e6a4063a7e9df3
Content-Type: text/plain; charset="UTF-8"

Hello,

I am trying to process an LTTng trace using babeltrace2's Python API. What
I want to do is add a new stream of events to an existing trace. My
approach is to create a custom source component that reads the existing
trace and forwards existing messages unchanged, but adds (interleaves, in
fact) some new events in a new stream.

So I have a custom UserMessageIterator that holds
a TraceCollectionMessageIterator that is reading from the original trace.
But if I output the unchanged events from the input iterator, that means
those events have a pre-baked trace and pre-baked trace class, to which I
am unable to add streams. (It seems that the C API may allow this, but the
Python one does not.) I could create a new trace class and a new stream for
my synthetic events, but then I'd have two parallel traces, and that's not
what I want (or is it? I'm new to all this).

For context, what I'm trying to achieve is to debug some erratic behavior
in an embedded Linux application, and I decided I'd like to see the
syscalls in the Flame Chart view in Trace Compass. So I'm my utility reads
all the syscall_entry_* and syscall_exit_* events and generates
corresponding func_entry and func_exit events. That part works fine -- but
getting the events into a trace alongside the existing events is what's
stymying me.

Thanks in advance for any help,

Alec

--000000000000a2e6a4063a7e9df3
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr">Hello,<div><br></div><div>I am trying to =
process an LTTng trace using babeltrace2&#39;s Python API. What I want to d=
o is add a new stream of events to an existing trace. My approach is to cre=
ate=C2=A0a custom source component that reads the existing trace and forwar=
ds existing messages unchanged, but adds (interleaves, in fact) some new ev=
ents in a new stream.</div><div><br></div><div>So I have a custom UserMessa=
geIterator that holds a=C2=A0TraceCollectionMessageIterator that is reading=
 from the original trace. But if I output the unchanged events from the inp=
ut iterator, that means those events have a pre-baked trace and pre-baked t=
race class, to which I am unable to add streams. (It seems that the C API m=
ay allow this, but the Python one does not.) I could create a new trace cla=
ss and a new stream for my synthetic events, but then I&#39;d have two para=
llel traces, and that&#39;s not what I want (or is it? I&#39;m new to all t=
his).</div><div><br></div><div>For context, what I&#39;m trying to achieve =
is to debug some erratic behavior in an embedded Linux application, and I d=
ecided I&#39;d like to see the syscalls in the Flame Chart view in Trace Co=
mpass. So I&#39;m my utility reads all the syscall_entry_* and syscall_exit=
_* events and generates corresponding func_entry and func_exit events. That=
 part works fine -- but getting the events into a trace alongside the exist=
ing events is what&#39;s stymying me.</div><div><br></div><div>Thanks in ad=
vance for any help,</div><div><br></div><div>Alec</div></div>
</div>

--000000000000a2e6a4063a7e9df3--