Skip to content

Commit 2fcb26a

Browse files
committed
test: fix UpDownCounter logic to account for temporality preference
1 parent a094cd9 commit 2fcb26a

File tree

1 file changed

+12
-20
lines changed
  • opentelemetry-sdk/src/metrics

1 file changed

+12
-20
lines changed

opentelemetry-sdk/src/metrics/mod.rs

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,11 @@ mod tests {
944944

945945
assert_eq!(sum.data_points.len(), 1, "Expected only one data point");
946946
assert!(!sum.is_monotonic, "Should not produce monotonic.");
947-
assert_eq!(sum.temporality, Temporality::Delta, "Should produce Delta");
947+
assert_eq!(
948+
sum.temporality,
949+
Temporality::Cumulative,
950+
"Should produce Cumulative for UpDownCounter"
951+
);
948952

949953
let data_point = &sum.data_points[0];
950954
assert!(data_point.attributes.is_empty(), "Non-empty attribute set");
@@ -2251,15 +2255,11 @@ mod tests {
22512255
!sum.is_monotonic,
22522256
"UpDownCounter should produce non-monotonic."
22532257
);
2254-
if let Temporality::Cumulative = temporality {
2255-
assert_eq!(
2256-
sum.temporality,
2257-
Temporality::Cumulative,
2258-
"Should produce cumulative"
2259-
);
2260-
} else {
2261-
assert_eq!(sum.temporality, Temporality::Delta, "Should produce delta");
2262-
}
2258+
assert_eq!(
2259+
sum.temporality,
2260+
Temporality::Cumulative,
2261+
"Should produce Cumulative for UpDownCounter"
2262+
);
22632263

22642264
// find and validate key1=value2 datapoint
22652265
let data_point1 = find_datapoint_with_key_value(&sum.data_points, "key1", "value1")
@@ -2288,19 +2288,11 @@ mod tests {
22882288
assert_eq!(sum.data_points.len(), 2);
22892289
let data_point1 = find_datapoint_with_key_value(&sum.data_points, "key1", "value1")
22902290
.expect("datapoint with key1=value1 expected");
2291-
if temporality == Temporality::Cumulative {
2292-
assert_eq!(data_point1.value, 10);
2293-
} else {
2294-
assert_eq!(data_point1.value, 5);
2295-
}
2291+
assert_eq!(data_point1.value, 10);
22962292

22972293
let data_point1 = find_datapoint_with_key_value(&sum.data_points, "key1", "value2")
22982294
.expect("datapoint with key1=value2 expected");
2299-
if temporality == Temporality::Cumulative {
2300-
assert_eq!(data_point1.value, 14);
2301-
} else {
2302-
assert_eq!(data_point1.value, 7);
2303-
}
2295+
assert_eq!(data_point1.value, 14);
23042296
}
23052297

23062298
fn find_datapoint_with_key_value<'a, T>(

0 commit comments

Comments
 (0)