fn add_network_stats()

in nfm-controller/src/reports/report_otlp.rs [163:197]


    fn add_network_stats(
        report: &NfmReport,
        timestamp_ns: u64,
        resource_metrics: &mut ResourceMetrics,
    ) {
        for network_stat in &report.network_stats {
            let mut scope_metrics = ScopeMetrics::default();

            let mut scope = InstrumentationScope {
                name: SCOPE_NAME_NETWORK_STAT.to_string(),
                ..Default::default()
            };

            // Flow information will be in the scope
            for (name, value) in network_stat.flow.enumerate() {
                scope.attributes.push(KeyValue {
                    key: name.to_string(),
                    value: Some(AnyValue {
                        value: Some(value.into()),
                    }),
                });
            }

            // List of metrics for the flow
            scope_metrics.scope = Some(scope);
            for (name, value) in network_stat.stats.enumerate() {
                match build_metric_histogram(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);
        }
    }