Module metrics

Module metrics 

Source
Expand description

Defines the metrics system for balloon devices.

§Metrics format

The metrics are flushed in JSON when requested by vmm::logger::metrics::METRICS.write().

§JSON example with metrics:

 "balloon": {
    "activate_fails": "SharedIncMetric",
    "inflate_count": "SharedIncMetric",
    "stats_updates_count": "SharedIncMetric",
    ...
 }
}

Each balloon field in the example above is a serializable BalloonDeviceMetrics structure collecting metrics such as activate_fails, inflate_count etc. for the balloon device. Since balloon doesn’t support multiple devices, there is no per device metrics and balloon represents the aggregate balloon metrics.

§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 balloon device metrics from logger module by moving BalloonDeviceMetrics out of FirecrackerDeviceMetrics.
  • Rely on serde to 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 balloon device metrics.