From 062738667a2d61e58cef337b1b1360f4db27fd76 Mon Sep 17 00:00:00 2001 From: Anush Nadathur Date: Mon, 17 Jun 2024 14:50:05 -0700 Subject: [PATCH] Addressed code review comments --- src/darwin/Framework/CHIP/MTRDevice.mm | 9 ++++----- src/darwin/Framework/CHIP/MTRMetricKeys.h | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/darwin/Framework/CHIP/MTRDevice.mm b/src/darwin/Framework/CHIP/MTRDevice.mm index 79b728ff197c0d..89db49f077cdca 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.mm +++ b/src/darwin/Framework/CHIP/MTRDevice.mm @@ -1177,8 +1177,6 @@ - (void)_handleSubscriptionEstablished { os_unfair_lock_lock(&self->_lock); - MATTER_LOG_METRIC_END(kMetricMTRDeviceSubscriptionSetup, CHIP_NO_ERROR); - // We have completed the subscription work - remove from the subscription pool. [self _clearSubscriptionPoolWork]; @@ -1187,6 +1185,7 @@ - (void)_handleSubscriptionEstablished if (HadSubscriptionEstablishedOnce(_internalDeviceState)) { [self _changeInternalState:MTRInternalDeviceStateLaterSubscriptionEstablished]; } else { + MATTER_LOG_METRIC_END(kMetricMTRDeviceInitialSubscriptionSetup, CHIP_NO_ERROR); [self _changeInternalState:MTRInternalDeviceStateInitialSubscriptionEstablished]; } @@ -1227,8 +1226,6 @@ - (void)_handleSubscriptionError:(NSError *)error { std::lock_guard lock(_lock); - MATTER_LOG_METRIC_END(kMetricMTRDeviceSubscriptionSetup, [MTRError errorToCHIPErrorCode:error]); - [self _changeInternalState:MTRInternalDeviceStateUnsubscribed]; _unreportedEvents = nil; @@ -2345,7 +2342,9 @@ - (void)_setupSubscriptionWithReason:(NSString *)reason }); } - MATTER_LOG_METRIC_BEGIN(kMetricMTRDeviceSubscriptionSetup); + // This marks begin of initial subscription to the device (before CASE is established). The end is only marked after successfully setting + // up the subscription since it is always retried as long as the MTRDevice is kept running. + MATTER_LOG_METRIC_BEGIN(kMetricMTRDeviceInitialSubscriptionSetup); // Call directlyGetSessionForNode because the subscription setup already goes through the subscription pool queue [_deviceController diff --git a/src/darwin/Framework/CHIP/MTRMetricKeys.h b/src/darwin/Framework/CHIP/MTRMetricKeys.h index ae7caa5ea764e5..22f6128968a32a 100644 --- a/src/darwin/Framework/CHIP/MTRMetricKeys.h +++ b/src/darwin/Framework/CHIP/MTRMetricKeys.h @@ -88,8 +88,8 @@ constexpr Tracing::MetricKey kMetricBLEDevicesRemoved = "dwnfw_ble_devices_remov // Unexpected C quality attribute update outside of priming constexpr Tracing::MetricKey kMetricUnexpectedCQualityUpdate = "dwnpm_bad_c_attr_update"; -// Subscription setup from darwin MTRDevice -constexpr Tracing::MetricKey kMetricMTRDeviceSubscriptionSetup = "dwnpm_dev_subscription_setup"; +// Setup from darwin MTRDevice for initial subscrption to a device +constexpr Tracing::MetricKey kMetricMTRDeviceInitialSubscriptionSetup = "dwnpm_dev_initial_subscription_setup"; } // namespace DarwinFramework } // namespace Tracing