feat: api-trace
[govpp.git] / examples / api-trace / README.md
1 # API trace example
2
3 The example demonstrates how to use GoVPP API trace functionality. Connection object `core.Connection` contains
4 API tracer able to record API messages sent to and from VPP.
5
6 Access to the tracer is done via `Trace()`. It allows accessing several methods to manage collected entries:
7 * `Enable(<bool>)` either enables or disables the trace. Note that the trace is disabled by default and messages are not recorded while so.
8 * `GetRecords() []*api.Record` provide messages collected since the plugin was enabled or cleared.
9 * `GetRecordsForChannel(<channelID>) []*api.Record` provide messages collected on the given channel since the plugin was enabled or cleared.
10 * `Clear()` removes recorded messages.
11
12 A record is represented by `Record` type. It contains information about the message, its direction, time and channel ID. Following fields are available:
13 * `Message api.Message` returns recorded entry as GoVPP Message.
14 * `Timestamp time.Time` is the message timestamp.
15 * `IsReceived bool` is true if the message is a reply or details message, false otherwise.
16 * `ChannelID uint16` is the ID of channel processing the traced message. 
17