Skip to content

Commit e6965bd

Browse files
utpillacijothomas
andauthored
[Metrics API] Remove unnecessary auto trait implementations (#2215)
Co-authored-by: Cijo Thomas <[email protected]>
1 parent 20f1204 commit e6965bd

File tree

3 files changed

+2
-36
lines changed

3 files changed

+2
-36
lines changed

opentelemetry-sdk/src/metrics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn calculate_hash(values: &[KeyValue]) -> u64 {
104104

105105
impl 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
}

opentelemetry/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Removed unnecessary public methods named `as_any` from `AsyncInstrument` trait and the implementing instruments: `ObservableCounter`, `ObservableGauge`, and `ObservableUpDownCounter` [#2187](https://github.com/open-telemetry/opentelemetry-rust/pull/2187)
88
- Introduced `SyncInstrument` trait to replace the individual synchronous instrument traits (`SyncCounter`, `SyncGauge`, `SyncHistogram`, `SyncUpDownCounter`) which are meant for SDK implementation. [#2207](https://github.com/open-telemetry/opentelemetry-rust/pull/2207)
99
- Ensured that `observe` method on asynchronous instruments can only be called inside a callback. This was done by removing the implementation of `AsyncInstrument` trait for each of the asynchronous instruments. [#2210](https://github.com/open-telemetry/opentelemetry-rust/pull/2210)
10+
- Removed `PartialOrd` and `Ord` implementations for `KeyValue`. [#2215](https://github.com/open-telemetry/opentelemetry-rust/pull/2215)
1011

1112
## v0.26.0
1213
Released 2024-Sep-30

opentelemetry/src/metrics/mod.rs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! # OpenTelemetry Metrics API
22
3-
use std::cmp::Ordering;
43
use std::hash::{Hash, Hasher};
54
use std::result;
65
use 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-
10793
impl 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);

0 commit comments

Comments
 (0)