Skip to content

Commit f45e840

Browse files
authored
[Metrics API] Mark KeyValue types non-exhaustive (#2228)
1 parent a47b429 commit f45e840

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

opentelemetry-proto/src/transform/common.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ pub mod tonic {
152152
Array::I64(vals) => array_into_proto(vals),
153153
Array::F64(vals) => array_into_proto(vals),
154154
Array::String(vals) => array_into_proto(vals),
155+
_ => unreachable!("Nonexistent array type"), // Needs to be updated when new array types are added
155156
})),
157+
_ => unreachable!("Nonexistent value type"), // Needs to be updated when new value types are added
156158
},
157159
}
158160
}

opentelemetry-stdout/src/common.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ impl From<opentelemetry::Value> for Value {
144144
opentelemetry::Array::String(s) => {
145145
Value::Array(s.into_iter().map(|s| Value::String(s.into())).collect())
146146
}
147+
_ => unreachable!("Nonexistent array type"), // Needs to be updated when new array types are added
147148
},
149+
_ => unreachable!("Nonexistent value type"), // Needs to be updated when new value types are added
148150
}
149151
}
150152
}

opentelemetry/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
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)
1010
- Removed `PartialOrd` and `Ord` implementations for `KeyValue`. [#2215](https://github.com/open-telemetry/opentelemetry-rust/pull/2215)
11-
- - **Breaking change for log exporter authors:** Marked `AnyValue` enum as `non_exhaustive`. [#2230](https://github.com/open-telemetry/opentelemetry-rust/pull/2230)
11+
- **Breaking change for exporter authors:** Marked `KeyValue` related structs and enums as `non_exhaustive`. [#2228](https://github.com/open-telemetry/opentelemetry-rust/pull/2228)
12+
- **Breaking change for log exporter authors:** Marked `AnyValue` enum as `non_exhaustive`. [#2230](https://github.com/open-telemetry/opentelemetry-rust/pull/2230)
1213

1314
## v0.26.0
1415
Released 2024-Sep-30

opentelemetry/src/common.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::{fmt, hash};
77
/// See the [attribute naming] spec for guidelines.
88
///
99
/// [attribute naming]: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/general/attribute-naming.md
10+
#[non_exhaustive]
1011
#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
1112
pub struct Key(OtelString);
1213

@@ -149,6 +150,7 @@ impl hash::Hash for OtelString {
149150
}
150151

151152
/// A [Value::Array] containing homogeneous values.
153+
#[non_exhaustive]
152154
#[derive(Clone, Debug, PartialEq)]
153155
pub enum Array {
154156
/// Array of bools
@@ -212,6 +214,7 @@ into_array!(
212214
);
213215

214216
/// The value part of attribute [KeyValue] pairs.
217+
#[non_exhaustive]
215218
#[derive(Clone, Debug, PartialEq)]
216219
pub enum Value {
217220
/// bool values
@@ -227,6 +230,7 @@ pub enum Value {
227230
}
228231

229232
/// Wrapper for string-like values
233+
#[non_exhaustive]
230234
#[derive(Clone, PartialEq, Eq, Hash)]
231235
pub struct StringValue(OtelString);
232236

@@ -372,6 +376,7 @@ impl fmt::Display for Value {
372376

373377
/// A key-value pair describing an attribute.
374378
#[derive(Clone, Debug, PartialEq)]
379+
#[non_exhaustive]
375380
pub struct KeyValue {
376381
/// The attribute name
377382
pub key: Key,

0 commit comments

Comments
 (0)