Watch
0
0
Fork
You've already forked hyperhive
0

metrics tests: compare labels sorted, the SDK keeps attributes in no fixed order

This commit is contained in:
damocles 2026-11-05 00:53:43 +01:00 • committed by mara
commit 4b71bcd8ff

View file

@ -190,10 +190,13 @@ mod tests {
for resource in exporter.get_finished_metrics().unwrap() {
for scope in resource.scope_metrics() {
for metric in scope.metrics().filter(|m| m.name() == name) {
// The SDK keeps attributes in no fixed order, so sort them.
let labels = |attrs: &mut dyn Iterator<Item = &KeyValue>| {
attrs
let mut all = attrs
.map(|kv| (kv.key.to_string(), kv.value.to_string()))
.collect::<Vec<_>>()
.collect::<Vec<_>>();
all.sort();
all
};
match metric.data() {
AggregatedMetrics::U64(MetricData::Sum(sum)) => {