aboutsummaryrefslogtreecommitdiffstats
path: root/examples/api-trace/README.md
blob: 6cb6ce887a226171426660dbf148ffc17dd72490 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# API trace example

The example demonstrates how to use GoVPP API trace functionality. Connection object `core.Connection` contains
API tracer able to record API messages sent to and from VPP.

Access to the tracer is done via `Trace()`. It allows accessing several methods to manage collected entries:
* `Enable(<bool>)` either enables or disables the trace. Note that the trace is disabled by default and messages are not recorded while so.
* `GetRecords() []*api.Record` provide messages collected since the plugin was enabled or cleared.
* `GetRecordsForChannel(<channelID>) []*api.Record` provide messages collected on the given channel since the plugin was enabled or cleared.
* `Clear()` removes recorded messages.

A record is represented by `Record` type. It contains information about the message, its direction, time and channel ID. Following fields are available:
* `Message api.Message` returns recorded entry as GoVPP Message.
* `Timestamp time.Time` is the message timestamp.
* `IsReceived bool` is true if the message is a reply or details message, false otherwise.
* `ChannelID uint16` is the ID of channel processing the traced message.