[lttng-dev] [lttng-ust] [babeltrace] use case question - field names in event classes
Julien Desfossez
jdesfossez at efficios.com
Wed Oct 12 15:23:51 UTC 2016
On 12-Oct-2016 08:51:46 AM, Staffan Tjernstrom wrote:
> >
> > In the code, before calling the associated `two_ints_and_string`
> > tracepoint, and only once:
> >
> > tracepoint(my_app, log_statement_field_names, 1,
> > "widget_height", "widget_width", "widget_name", "");
> >
> > Then:
> >
> > tracepoint(my_app, two_ints_and_string, 1, height, width, name);
> >
> > Then in your Python script you can register the dynamic field names
> > when
> > you get a `log_statement_field_names` event and use them when you get
> > a
> > "real" event (not tested):
> >
> > id_to_field_names = {}
> >
> > # open trace, etc.
> >
> > # some loop over the trace's events:
> > if evt.name == 'log_statement_field_names':
> > field_names = (evt['arg1'], evt['arg2'], evt['arg3'],
> > evt['arg4'])
> > id_to_field_names[evt['id']] = field_names
> > elif evt.name == 'two_ints_and_string':
> > field_names = id_to_field_names[evt['id']]
> > print('{}: {}'.format(field_names[0], evt['value1']))
> > print('{}: {}'.format(field_names[1], evt['value2']))
> > print('{}: {}'.format(field_names[2], evt['value3']))
> > print()
> >
> > Now this is a great use case for future extensions of LTTng-UST and/or
> > the upcoming CTF 2.
> >
> > Phil
> >
> Thanks - I hadn't thought of the Python bindings - I think we could
> make that work (maybe wrapping the two tracepoint incantations into a
> single macro definition).
If you want some help generating the boiler plate Python code for
parsing your trace, I recommend the parser_generator.py script from
lttng-analyses:
https://github.com/lttng/lttng-analyses/blob/master/parser_generator.py
Julien
More information about the lttng-dev
mailing list