in nfm-controller/src/reports/report_otlp.rs [48:90]
fn build_metric_histogram(
name: String,
timestamp_ns: u64,
value: ReportValue,
) -> Result<Metric, String> {
let mut data_point = HistogramDataPoint {
time_unix_nano: timestamp_ns,
start_time_unix_nano: timestamp_ns,
count: 1,
..Default::default()
};
match value {
ReportValue::Float(value) => {
data_point.sum = Some(value);
}
ReportValue::Int(value) => {
data_point.sum = Some(value as f64);
}
ReportValue::UInt(value) => {
data_point.sum = Some(value as f64);
}
ReportValue::Histogram(histo) => {
data_point.count = histo.count.into();
data_point.min = Some(histo.min.into());
data_point.max = Some(histo.max.into());
data_point.sum = Some(histo.sum as f64);
}
_ => {
return Err(format!("Unsupported value type {:?}", value).to_string());
}
}
let data = Data::Histogram(Histogram {
data_points: vec![data_point],
aggregation_temporality: AggregationTemporality::Delta.into(),
});
Ok(Metric {
name: name.to_string(),
data: Some(data),
..Default::default()
})
}