Skip to content

Commit 833cafd

Browse files
committed
fix: nit followups from View cleanup
1 parent e123996 commit 833cafd

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

opentelemetry-sdk/src/metrics/instrument.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ impl InstrumentKind {
6868
/// Describes properties an instrument is created with, used for filtering in
6969
/// [View](crate::metrics::View)s.
7070
///
71-
/// A reference to `Instrument` is provided to the `view` to select the
72-
/// instrument(s) for which the [Stream] should be applied.
71+
/// Users can utilize a reference to `Instrument` to select the instrument(s)
72+
/// for which the [Stream] should be applied.
7373
///
7474
/// # Example
7575
///
@@ -78,7 +78,7 @@ impl InstrumentKind {
7878
///
7979
/// let my_view_change_cardinality = |i: &Instrument| {
8080
/// if i.name() == "my_second_histogram" {
81-
/// // Note: If Stream is invalid, build() will return an error. By
81+
/// // Note: If Stream is invalid, `build()` will return an error. By
8282
/// // calling `.ok()`, any such error is ignored and treated as if the
8383
/// // view does not match the instrument. If this is not the desired
8484
/// // behavior, consider handling the error explicitly.
@@ -185,8 +185,8 @@ impl StreamBuilder {
185185
/// Set the stream allowed attribute keys.
186186
///
187187
/// Any attribute recorded for the stream with a key not in this set will be
188-
/// dropped. If the set is empty, all attributes will be dropped, if `None` all
189-
/// attributes will be kept.
188+
/// dropped. If the set is empty, all attributes will be dropped.
189+
/// If not set, all attributes will be kept.
190190
pub fn with_allowed_attribute_keys(
191191
mut self,
192192
attribute_keys: impl IntoIterator<Item = Key>,
@@ -256,7 +256,9 @@ fn validate_bucket_boundaries(boundaries: &[f64]) -> Result<(), String> {
256256
// validate that buckets are sorted and non-duplicate
257257
for i in 1..boundaries.len() {
258258
if boundaries[i] <= boundaries[i - 1] {
259-
return Err("Bucket boundaries must be sorted and non-duplicate".to_string());
259+
return Err(
260+
"Bucket boundaries must be sorted and not contain any duplicates".to_string(),
261+
);
260262
}
261263
}
262264

opentelemetry-sdk/src/metrics/meter_provider.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ impl MeterProviderBuilder {
348348
/// // By calling `.ok()`, any such error is ignored and treated as if the view does not match
349349
/// // the instrument.
350350
/// // If this is not the desired behavior, consider handling the error explicitly.
351-
/// Stream::builder().with_cardinality_limit(100).build().ok()
351+
/// Stream::builder().with_cardinality_limit(0).build().ok()
352352
/// } else {
353353
/// None
354354
/// }

opentelemetry-sdk/src/metrics/mod.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -940,12 +940,10 @@ mod tests {
940940
// View drops all attributes.
941941
let view = |i: &Instrument| {
942942
if i.name == "my_observable_counter" {
943-
Some(
944-
Stream::builder()
945-
.with_allowed_attribute_keys(vec![])
946-
.build()
947-
.unwrap(),
948-
)
943+
Stream::builder()
944+
.with_allowed_attribute_keys(vec![])
945+
.build()
946+
.ok()
949947
} else {
950948
None
951949
}

0 commit comments

Comments
 (0)