fn add_host_stats()

in nfm-controller/src/reports/report_otlp.rs [199:230]


    fn add_host_stats(
        report: &NfmReport,
        timestamp_ns: u64,
        resource_metrics: &mut ResourceMetrics,
    ) {
        for grouped_stats in &report.host_stats.interface_stats {
            let mut scope_metrics = ScopeMetrics::default();
            let mut scope = InstrumentationScope {
                name: SCOPE_NAME_HOST_STAT.to_string(),
                ..Default::default()
            };

            // The scope will contain the interface ID.
            scope.attributes.push(KeyValue {
                key: "interface_id".to_string(),
                value: Some(AnyValue {
                    value: Some(Value::StringValue(grouped_stats.interface_id.clone())),
                }),
            });

            // List of metrics for the flow
            scope_metrics.scope = Some(scope);
            for (name, value) in grouped_stats.stats.enumerate() {
                match build_metric_sum(name, timestamp_ns, value) {
                    Ok(metric) => scope_metrics.metrics.push(metric),
                    Err(e) => error!(msg = e; "Error building metric"),
                }
            }

            resource_metrics.scope_metrics.push(scope_metrics);
        }
    }