HawkTracer
0.10.0
|
HTDUMP data format is a binary event format designed for efficient storage of data generated by HawkTracer library. The format is very flexible in a way that user can define custom event types without modifying the source code of the event parser. As mentioned above, format allows user to define custom event classes. However, there are a few pre-defined classes which must be known for the parser in advance:
Event
- (see Base event class)EndiannessInfoEvent
- (see Endianness)EventKlassInfoEvent
- (see Custom event classes)EventKlassFieldInfoEvent
- (see Custom event classes)HTDUMP format allows user to define custom event classes. Moreover, it allows to use user-defined class as a base class for other event class. However, all the event classes must directly or indirectly inherit from the Event class, which contains base data and all necessary information for parsing events of that class:
Each event class has unique class identifier, which is used by parser to know how to parse a particular event. timestamp
is used to determine when exactly the event happened in the system, and event_id
is just a sequence number of the event (in case user needed to distinguish multiple events).
All the generated events are packed into the stream which then is parsed by the client application. Events in the stream can be in a different order (they don't have to be sorted by event_id
or timestamp
), however, there are 2 rules that every stream needs to follow:
EventKlassInfoEvent
and EventKlassFieldInfoEvent
events of the particular event class must be placed in the stream before any instance of that class - parser reads the stream from the beginning to the end, and if there's an event of which the type is not known to the parser yet, parsing process will fail.EndiannessInfoEvent
shoudl be the first event of the stream - if not, the parser will choose default endianness, which might not be correct for the stream.HawkTracer is intended to be used on various platforms with different CPUs, therefore at the very beginning of the event stream, the endianness of the platform must be specified. It's done by sending an event of EndiannessInfoEvent class:
The parser uses the klass_id
field of the event to determine which klass description to use for parsing the event. However, before sending EndiannessInfoEvent parser doesn't know what the endianness is, so it's not possible to parse the field properly. To overcome the problem, EndiannessInfoEvent class uses 0
as class identifier, as it's the same value regardless of the endianness.
To define custom event type, user needs to push the event class description to the event stream before pushing events of this class, so parser knows how to deal with this type of event. There are 2 event types that should be used to describe a new data type:
EventKlassInfoEvent
- contains information about the new event class: EventKlassFieldInfoEvent
- describes each event class field separately. Number of events of this type for a particular event class shoudl match the value of field_count
from EventKlassInfoEvent
event. DataType
is an enum, which is defined as follows: Assume we want to create an event class with following fields:
Before sending an event of this type to the event stream, there should be 4 events send before that: