From mboxrd@z Thu Jan 1 00:00:00 1970 From: staffan@eternaltraveller.com (Staffan Tjernstrom) Date: Wed, 12 Oct 2016 08:51:46 -0500 Subject: [lttng-dev] [lttng-ust] [babeltrace] use case question - field names in event classes In-Reply-To: References: <8867c80160a75f382ac5dd3f50d2014b.squirrel@email.powweb.com> Message-ID: <7110ec441dc2f14caee4a447826c31f7.squirrel@email.powweb.com> > > 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 > >> >> _______________________________________________ >> lttng-dev mailing list >> lttng-dev at lists.lttng.org >> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev > 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). Staffan Tj.