Skip to content

Commit

Permalink
feat(metrics)(net): Use Arc to allow storing metris in Net
Browse files Browse the repository at this point in the history
Use Arc for NetDeviceMetrics since this allows us to store
NetDeviceMetrics directly inside Net and get rid of the
net_metrics! macro.
Also, use better name for net metrics.

Note: this is part 12 of 12 commits to add per net device metrics.

Signed-off-by: Sudan Landge <sudanl@amazon.com>
  • Loading branch information
Sudan Landge authored and wearyzen committed Oct 18, 2023
1 parent 1e97bf4 commit 00524a7
Show file tree
Hide file tree
Showing 6 changed files with 283 additions and 231 deletions.
12 changes: 6 additions & 6 deletions src/vmm/src/devices/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ pub mod virtio;
pub use bus::{Bus, BusDevice, BusError};
use log::error;

use crate::devices::virtio::metrics::NetDeviceMetrics;
use crate::devices::virtio::{QueueError, VsockError};
use crate::logger::{IncMetric, METRICS};
use crate::net_metrics;

// Function used for reporting error in terms of logging
// but also in terms of metrics of net event fails.
// network metrics is reported per device so we need `net_iface_id`
// to identify which device the metrics and `err` should be reported for.
pub(crate) fn report_net_event_fail(net_iface_id: &String, err: DeviceError) {
error!("{:?}:{:?}", net_iface_id, err);
net_metrics!(net_iface_id, event_fails.inc());
// network metrics is reported per device so we need a handle to each net device's
// metrics `net_iface_metrics` to report metrics for that device.
pub(crate) fn report_net_event_fail(net_iface_metrics: &NetDeviceMetrics, err: DeviceError) {
error!("{:?}", err);
net_iface_metrics.event_fails.inc();
}

pub(crate) fn report_balloon_event_fail(err: virtio::balloon::BalloonError) {
Expand Down
Loading

0 comments on commit 00524a7

Please sign in to comment.