LTTNG_UST_TRACEF(3)
π LTTNG_UST_TRACEF(3) β the lttng_ust_tracef / lttng_ust_vtracef era
okay so bestie, this is a page from the LTTng Manual, and it's literally about the lttng_ust_tracef() and lttng_ust_vtracef() girlies β the printf(3)-like interface for tracing. no cap, it's giving "easy mode for user space tracing" β¨
πΈ NAME πΈ
lttng_ust_tracef, lttng_ust_vtracef β the LTTng-UST printf(3)-like interface, periodt π
π SYNOPSIS π
#include <lttng/tracef.h>
#define lttng_ust_tracef(fmt, ...)
#define lttng_ust_vtracef(fmt, ap)
Link with:
-llttng-ust- If you define
_LGPL_SOURCEbefore including<lttng/tracef.h>(directly or indirectly):-llttng-ust-common
yes bestie, that second one is conditional β define_LGPL_SOURCEfirst or the-llttng-ust-commonlink line is not the vibe π
π¦ DESCRIPTION π¦
So the LTTng-UST lttng_ust_tracef() and lttng_ust_vtracef() API lets you trace your app with the help of simple printf(3)-like and vprintf(3)-like macros. iconic behavior honestly π
The fmt argument gets passed directly as the fmt parameter of vasprintf(3), and also:
- For
lttng_ust_tracef()β the optional parameters following fmt. - For
lttng_ust_vtracef()β the ap parameter, as the ap parameter ofvasprintf(3)(va_listtype).
To use lttng_ust_tracef() or lttng_ust_vtracef(), include <lttng/tracef.h> wherever you need it, and link your application with liblttng-ust and liblttng-ust-common. there's a whole complete usage example down in the EXAMPLE section, iykyk π
Once your app is instrumented with lttng_ust_tracef() and/or lttng_ust_vtracef() calls and ready to run, use lttng-enable-event(1) to enable the lttng_ust_tracef:* event. slay β¨
The lttng_ust_tracef() and lttng_ust_vtracef() events contain a single field, named msg, which is the formatted string output. that's the whole field list, that's the girl π
If you need to attach a specific log level to a lttng_ust_tracef()/lttng_ust_vtracef() call, use lttng_ust_tracelog(3) and lttng_ust_vtracelog(3) instead. different function, different vibe π
Also pls check the LIMITATIONS section below for important limitations to consider when using lttng_ust_tracef() or lttng_ust_vtracef() β no skipping, it's important π«Ά
π EXAMPLE π
Here's a usage example of lttng_ust_tracef():
#include <stdlib.h>
#include <lttng/tracef.h>
int main(void)
{
int i;
for (i = 0; i < 25; i++) {
lttng_ust_tracef("my message: %s, this integer: %d",
"a message", i);
}
return EXIT_SUCCESS;
}
This C source file, saved as app.c, can be compiled into a program like this:
$ cc -o app app.c -llttng-ust -llttng-ust-common
You can create an LTTng tracing session, enable the lttng_ust_tracef() events, and start the created tracing session like this:
$ lttng create my-session
$ lttng enable-event --userspace 'lttng_ust_tracef:*'
$ lttng start
Next, start the program to be traced:
$ ./app
Finally, stop the tracing session, and inspect the recorded events:
$ lttng stop
$ lttng view
and that's it, that's the whole ritual π₯
π LIMITATIONS π
okay bestie, sit down for this one. the lttng_ust_tracef() and lttng_ust_vtracef() utility macros were developed to make user space tracing super simple, albeit with notable disadvantages compared to custom, full-fledged tracepoint providers. it's giving tradeoffs, fr fr:
- All generated events have the same provider/event names. same name, every time π«
- There's no static type checking. none. zero. π
- The only event field with user data you actually get, named
msg, is a string potentially containing the values you passed to the macro using your own format. This also means that you cannot use filtering using a custom expression at run time because there are no isolated fields. so no cute per-field filtering for you π - Since
lttng_ust_tracef()andlttng_ust_vtracef()use C standard library'svasprintf(3)function in the background to format the strings at run time, their expected performance is lower than using custom tracepoint providers with typed fields, which do not require a conversion to a string. slower, but honest πΈ - Generally, a string containing the textual representation of the user data fields is not as compact as binary fields in the resulting trace. bigger traces, more bytes, more storage, you get it π¦
Thus, lttng_ust_tracef()/lttng_ust_vtracef() are useful for quick prototyping and debugging, but should not be considered for any permanent/serious application instrumentation. read that again bestie. prototyping and debugging only β do not make it your permanent main character β οΈ
lttng_ust_vtracef() does not have a STAP_PROBEV() call, because STAP_PROBEV() does not support va_list. If you need it, you should emit this call yourself. diy queen π οΈ
See lttng-ust(3) to learn more about custom tracepoint providers. those are the upgrade path, no cap β¨
π BUGS π
If you encounter any issue or usability problem, please report it on the LTTng bug tracker <https://bugs.lttng.org/projects/lttng-ust>. bestie please tell them, they wanna know π
π RESOURCES π
- LTTng project website <http://lttng.org>
- LTTng documentation <http://lttng.org/docs>
- Git repositories <http://git.lttng.org>
- GitHub organization <http://github.com/lttng>
- Continuous integration <http://ci.lttng.org/>
- Mailing list <http://lists.lttng.org> for support and development:
lttng-dev@lists.lttng.org - IRC channel <irc://irc.oftc.net/lttng>:
#lttngonirc.oftc.net
like, the whole community is right there, go say hi π
π COPYRIGHTS π
This macro is part of the LTTng-UST project.
This macro is distributed under the GNU Lesser General Public License, version 2.1 <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html>. See the COPYING <https://github.com/lttng/lttng-ust/blob/v2.16/COPYING> file for more details. π
π§ THANKS π§
Thanks to Ericsson for funding this work, providing real-life use cases, and testing. real ones π«Ά
Special thanks to Michel Dagenais and the DORSAL laboratory <http://www.dorsal.polymtl.ca/> at Γcole Polytechnique de MontrΓ©al for the LTTng journey. iconic collaboration, honestly π
β AUTHORS β
LTTng-UST was originally written by Mathieu Desnoyers, with additional contributions from various other people. It is currently maintained by Mathieu Desnoyers <mailto:mathieu.desnoyers@efficios.com>. main character energy π
πΊ SEE ALSO πΊ
lttng_ust_tracelog(3), lttng_ust_vtracelog(3), lttng-ust(3), lttng(1), printf(3)
okay that's the whole page bestie, go trace something cute π
this lil drop is from LTTng 2.16.0, dated 08/31/2026 β and it's the LTTNG_UST_TRACEF(3) page, signing off πβ¨π¦
π¦ where this page comes from
- arch rolling: lttng-ust 2.16.0-1 Β· LGPL-2.1-only AND MIT AND GPL-2.0-only AND BSD-3-Clause AND BSD-2-Clause AND GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms