Skip to content

Commit 06523c2

Browse files
[Darwin] Always capture last value for metric end event (#39733)
- When collecting metrics for end event, make sure to always capture the value allowing overwrite of the value if it has already been logged previously. This is to allow last writer always wins. Co-authored-by: Andrei Litvin <[email protected]>
1 parent cfa1329 commit 06523c2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/darwin/Framework/CHIP/MTRMetricsCollector.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ - (void)handleMetricEvent:(MetricEvent)event
240240
}
241241
}
242242

243-
// Add to the collection only if it does not exist as yet.
244-
if (![_metricsDataCollection valueForKey:metricsKey]) {
243+
// Add to the collection only if it does not exist as yet or pick latest value for instant event
244+
if (![_metricsDataCollection valueForKey:metricsKey] || event.type() == MetricEvent::Type::kInstantEvent) {
245245
[_metricsDataCollection setValue:data forKey:metricsKey];
246246
}
247247
}

0 commit comments

Comments
 (0)