metrics tests: compare labels sorted, the SDK keeps attributes in no fixed order
This commit is contained in:
parent
3adfcb3843
commit
4b71bcd8ff
1 changed files with 12 additions and 6 deletions
|
|
@ -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)) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue