File tree Expand file tree Collapse file tree 2 files changed +1
-36
lines changed
opentelemetry-sdk/src/metrics
opentelemetry/src/metrics Expand file tree Collapse file tree 2 files changed +1
-36
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ fn calculate_hash(values: &[KeyValue]) -> u64 {
104104
105105impl AttributeSet {
106106 fn new ( mut values : Vec < KeyValue > ) -> Self {
107- values. sort_unstable ( ) ;
107+ values. sort_unstable_by ( |a , b| a . key . cmp ( & b . key ) ) ;
108108 let hash = calculate_hash ( & values) ;
109109 AttributeSet ( values, hash)
110110 }
Original file line number Diff line number Diff line change 11//! # OpenTelemetry Metrics API
22
3- use std:: cmp:: Ordering ;
43use std:: hash:: { Hash , Hasher } ;
54use std:: result;
65use std:: sync:: Arc ;
@@ -91,19 +90,6 @@ impl Hash for KeyValue {
9190 }
9291}
9392
94- impl PartialOrd for KeyValue {
95- fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
96- Some ( self . cmp ( other) )
97- }
98- }
99-
100- /// Ordering is based on the key only.
101- impl Ord for KeyValue {
102- fn cmp ( & self , other : & Self ) -> Ordering {
103- self . key . cmp ( & other. key )
104- }
105- }
106-
10793impl Eq for KeyValue { }
10894
10995/// SDK implemented trait for creating instruments
@@ -300,27 +286,6 @@ mod tests {
300286 }
301287 }
302288
303- #[ test]
304- fn kv_float_order ( ) {
305- // TODO: Extend this test to all value types, not just F64
306- let float_vals = [
307- 0.0 ,
308- 1.0 ,
309- -1.0 ,
310- f64:: INFINITY ,
311- f64:: NEG_INFINITY ,
312- f64:: NAN ,
313- f64:: MIN ,
314- f64:: MAX ,
315- ] ;
316-
317- for v in float_vals {
318- let kv1 = KeyValue :: new ( "a" , v) ;
319- let kv2 = KeyValue :: new ( "b" , v) ;
320- assert ! ( kv1 < kv2, "Order is solely based on key!" ) ;
321- }
322- }
323-
324289 fn hash_helper < T : Hash > ( item : & T ) -> u64 {
325290 let mut hasher = DefaultHasher :: new ( ) ;
326291 item. hash ( & mut hasher) ;
You can’t perform that action at this time.
0 commit comments