lisa.trace.MetaTxtTraceParser#
- class lisa.trace.MetaTxtTraceParser(*args, **kwargs)[source]#
Bases:
SimpleTxtTraceParser
Textual trace parser to parse meta-events.
- Parameters:
time (collections.abc.Iterable(float)) – Iterable of timestamps matching
lines
.
Meta events are events “embedded” as a string inside the field of another event. They are expected to comply with the raw format as output by
trace-cmd report -R
.Classes
Trace event parser for raw output of
trace-cmd report -R trace.dat
.Attributes
Mapping of event names to parser description as a dict.
Default regex to use to parse event header. It must parse the following groups:.
DTYPE_INFERENCE_ORDER
inheritedWhen the dtype of a field is not provided by a user-defined parser, these dtypes will be tried in order to convert the column from string to something more appropriate.
HEADER_FIELDS
inheritedPandas dtype of the header fields.
METADATA_KEYS
inheritedPossible metadata keys.
Properties
logger
inheritedConvenience short-hand for
self.get_logger()
.Methods
__enter__()
inherited__exit__()
inheritedfactory()
inheritedDecorator to use on alternative constructors, i.e. classmethods that return instances of the class.
from_string()
inheritedBuild an instance from a single multiline string.
from_txt_file()
inheritedBuild an instance from a path to a text file.
get_all_metadata()
inheritedCollect all available metadata.
get_logger()
inheritedProvides a
logging.Logger
named aftercls
.get_metadata()
inheritedReturn the metadata value.
get_parser_id()
inheritedGet the unique ID of that parser. Any parameter affecting the output dataframes or metadata must be somehow part of that ID, so that the cache is not accidentally hit with stale data.
log_locals()
inheritedDebugging aid: log the local variables of the calling function.
parse_all_events()
inheritedParse all available events.
parse_event()
inheritedParse the given event from the trace and return a
pandas.DataFrame
with the following columns:.parse_events()
inheritedSame as
parse_event()
but taking a list of events as input, and returning a mapping of event names topandas.DataFrame
for each.
Classes#
- class MetaTxtTraceParser.DEFAULT_EVENT_PARSER_CLS(event, fields, positional_field=None, greedy_field=None, raw=True)[source]#
Bases:
TxtEventParser
- PARSER_REGEX_TERMINALS = {'blank': ' +', 'floating': '\\d+\\.\\d+', 'identifier': '\\w+', 'integer': '\\d+'}#
Inherited attribute, see
lisa.trace.EventParserBase.PARSER_REGEX_TERMINALS
Snippets of regex to be used in building more complex regexes in textual trace parsers.
- __init_subclass__()#
Inherited method, see
object.__init_subclass__()
- __new__()#
Inherited method, see
object.__new__()
- __subclasshook__()#
Inherited method, see
object.__subclasshook__()
- property bytes_regex#
Inherited property, see
lisa.trace.TxtEventParser.bytes_regex
Attributes#
- MetaTxtTraceParser.EVENT_DESCS = {'userspace@rtapp_event': {'fields': {'desc': 'string', 'id': 'uint32', 'type': 'uint32'}}, 'userspace@rtapp_loop': {'fields': {'event': 'string', 'phase': 'uint32', 'phase_loop': 'uint32', 'thread_loop': 'uint32'}}, 'userspace@rtapp_main': {'fields': {'data': None, 'event': 'string'}}, 'userspace@rtapp_stats': {'fields': {'c_period': 'uint64', 'c_run': 'uint64', 'period': 'uint64', 'run': 'uint64', 'slack': 'uint64', 'wa_lat': 'uint64'}}, 'userspace@rtapp_task': {'fields': {'event': 'string'}}}#
Mapping of event names to parser description as a dict.
Each event description can include the following dict keys:
header_regex
: Regex to parse the event header. If not set, the header regex from the trace parser will be used.fields_regex
: Regex to parse the fields part of the event (i.e. the part after the header). This is the most commonly modified setting to take into account special cases in event formatting.fields
: Mapping of field names topandas.DataFrame
column dtype. This allows using a smaller dtype or the use of a non-inferred dtype likeboolean
.positional_field
: Name of the positional field (comming before the named fields). IfNone
, the column will be suppressed in the parsed dataframe.
- MetaTxtTraceParser.HEADER_REGEX = '(?P<__event>[\\w@]+):?'#
Default regex to use to parse event header. It must parse the following groups:
__timestamp
: the timestamp of the event__event
: the name of the event__cpu
(optional): the CPU by which the event was emitted__pid
(optional): the currently scheduled PID at the point the event was emitted__comm
(optional): the currently scheduled task’s name at the point the event was emitted
Note
It must not capture the event fields, as it will be concatenated with the field regex of each event to parse full lines.
- MetaTxtTraceParser.DTYPE_INFERENCE_ORDER = ['int64', 'uint64', 'float64']#
Inherited attribute, see
lisa.trace.TxtTraceParserBase.DTYPE_INFERENCE_ORDER
When the dtype of a field is not provided by a user-defined parser, these dtypes will be tried in order to convert the column from string to something more appropriate.
- MetaTxtTraceParser.HEADER_FIELDS = {'__comm': 'string', '__cpu': 'uint32', '__event': 'string', '__pid': 'uint32', '__timestamp': 'float64'}#
Inherited attribute, see
lisa.trace.TxtTraceParserBase.HEADER_FIELDS
Pandas dtype of the header fields.
- MetaTxtTraceParser.METADATA_KEYS = ['time-range', 'symbols-address', 'cpus-count', 'available-events', 'trace-id']#
Inherited attribute, see
lisa.trace.TraceParserBase.METADATA_KEYS
Possible metadata keys.
Properties#
- property MetaTxtTraceParser.logger#
Inherited property, see
lisa.utils.Loggable.logger
Convenience short-hand for
self.get_logger()
.
Methods#
- MetaTxtTraceParser.__enter__()#
Inherited method, see
lisa.trace.TraceParserBase.__enter__()
- MetaTxtTraceParser.__exit__(*args, **kwargs)#
Inherited method, see
lisa.trace.TraceParserBase.__exit__()
- classmethod MetaTxtTraceParser.factory(f)#
Inherited method, see
lisa.utils.PartialInit.factory()
Decorator to use on alternative constructors, i.e. classmethods that return instances of the class.
- classmethod MetaTxtTraceParser.from_string(txt, path=None, *, events=None, needed_metadata=None, event_parsers=None, default_event_parser_cls=None, pre_filled_metadata=None, temp_dir)#
Inherited method, see
lisa.trace.TxtTraceParserBase.from_string()
Build an instance from a single multiline string.
- classmethod MetaTxtTraceParser.from_txt_file(path, *, events=None, needed_metadata=None, event_parsers=None, default_event_parser_cls=None, pre_filled_metadata=None, temp_dir)#
Inherited method, see
lisa.trace.TxtTraceParserBase.from_txt_file()
Build an instance from a path to a text file.
- MetaTxtTraceParser.get_all_metadata()#
Inherited method, see
lisa.trace.TraceParserBase.get_all_metadata()
Collect all available metadata.
- classmethod MetaTxtTraceParser.get_logger(suffix=None)#
Inherited method, see
lisa.utils.Loggable.get_logger()
Provides a
logging.Logger
named aftercls
.
- MetaTxtTraceParser.get_metadata(key)#
Inherited method, see
lisa.trace.TxtTraceParserBase.get_metadata()
Return the metadata value.
- MetaTxtTraceParser.get_parser_id()#
Inherited method, see
lisa.trace.TraceParserBase.get_parser_id()
Get the unique ID of that parser. Any parameter affecting the output dataframes or metadata must be somehow part of that ID, so that the cache is not accidentally hit with stale data.
- classmethod MetaTxtTraceParser.log_locals(var_names=None, level='debug')#
Inherited method, see
lisa.utils.Loggable.log_locals()
Debugging aid: log the local variables of the calling function.
- MetaTxtTraceParser.parse_all_events()#
Inherited method, see
lisa.trace.TraceParserBase.parse_all_events()
Parse all available events.
- MetaTxtTraceParser.parse_event(event)#
Inherited method, see
lisa.trace.TxtTraceParserBase.parse_event()
Parse the given event from the trace and return a
pandas.DataFrame
with the following columns:.
- MetaTxtTraceParser.parse_events(events, best_effort=False, **kwargs)#
Inherited method, see
lisa.trace.TraceParserBase.parse_events()
Same as
parse_event()
but taking a list of events as input, and returning a mapping of event names topandas.DataFrame
for each.