Expand description
Defines the metrics system for vsock devices.
§Metrics format
The metrics are flushed in JSON when requested by vmm::logger::metrics::METRICS.write().
§JSON example with metrics:
"vsock": {
"activate_fails": "SharedIncMetric",
"cfg_fails": "SharedIncMetric",
"rx_queue_event_fails": "SharedIncMetric",
"tx_queue_event_fails": "SharedIncMetric",
"ev_queue_event_fails": "SharedIncMetric",
"muxer_event_fails": "SharedIncMetric",
...
}
}Each vsock field in the example above is a serializable VsockDeviceMetrics structure
collecting metrics such as activate_fails, cfg_fails, etc. for the Vsock device.
Since vsock doesn’t support multiple devices, there is no per device metrics and
vsock represents the aggregate metrics for all vsock connections.
§Design
The main design goals of this system are:
- Have a consistent approach of keeping device related metrics in the individual devices modules.
- To decouple vsock device metrics from logger module by moving VsockDeviceMetrics out of FirecrackerDeviceMetrics.
- Rely on
serdeto provide the actual serialization for writing the metrics.
The system implements 1 type of metrics:
- Shared Incremental Metrics (SharedIncMetrics) - dedicated for the metrics which need a counter (i.e the number of times an API request failed). These metrics are reset upon flush.
Functions§
- flush_
metrics - Called by METRICS.flush(), this function facilitates serialization of vsock device metrics.