Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn calculate_hash(values: &[KeyValue]) -> u64 {

impl AttributeSet {
fn new(mut values: Vec<KeyValue>) -> Self {
values.sort_unstable();
values.sort_unstable_by(|a, b| a.key.cmp(&b.key));
let hash = calculate_hash(&values);
AttributeSet(values, hash)
}
Expand Down
35 changes: 0 additions & 35 deletions opentelemetry/src/metrics/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! # OpenTelemetry Metrics API

use std::cmp::Ordering;
use std::hash::{Hash, Hasher};
use std::result;
use std::sync::Arc;
Expand Down Expand Up @@ -91,19 +90,6 @@ impl Hash for KeyValue {
}
}

impl PartialOrd for KeyValue {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}

/// Ordering is based on the key only.
impl Ord for KeyValue {
fn cmp(&self, other: &Self) -> Ordering {
self.key.cmp(&other.key)
}
}

impl Eq for KeyValue {}

/// SDK implemented trait for creating instruments
Expand Down Expand Up @@ -300,27 +286,6 @@ mod tests {
}
}

#[test]
fn kv_float_order() {
// TODO: Extend this test to all value types, not just F64
let float_vals = [
0.0,
1.0,
-1.0,
f64::INFINITY,
f64::NEG_INFINITY,
f64::NAN,
f64::MIN,
f64::MAX,
];

for v in float_vals {
let kv1 = KeyValue::new("a", v);
let kv2 = KeyValue::new("b", v);
assert!(kv1 < kv2, "Order is solely based on key!");
}
}

fn hash_helper<T: Hash>(item: &T) -> u64 {
let mut hasher = DefaultHasher::new();
item.hash(&mut hasher);
Expand Down
Loading