Skip to content

Commit 00524a7

Browse files
Sudan Landgewearyzen
authored andcommitted
feat(metrics)(net): Use Arc to allow storing metris in Net
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 <[email protected]>
1 parent 1e97bf4 commit 00524a7

File tree

6 files changed

+283
-231
lines changed

6 files changed

+283
-231
lines changed

src/vmm/src/devices/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ pub mod virtio;
1717
pub use bus::{Bus, BusDevice, BusError};
1818
use log::error;
1919

20+
use crate::devices::virtio::metrics::NetDeviceMetrics;
2021
use crate::devices::virtio::{QueueError, VsockError};
2122
use crate::logger::{IncMetric, METRICS};
22-
use crate::net_metrics;
2323

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

3333
pub(crate) fn report_balloon_event_fail(err: virtio::balloon::BalloonError) {

0 commit comments

Comments
 (0)