From 4ea71226a1c5fd31b6432f40a9bf1582f811e9f3 Mon Sep 17 00:00:00 2001 From: Anush Nadathur Date: Thu, 22 Feb 2024 23:58:12 +0530 Subject: [PATCH] Sample code of how Begin and End log metrics can be used --- src/darwin/Framework/CHIP/MTRDeviceController.mm | 4 ++++ .../Framework/CHIP/MTRDeviceControllerDelegateBridge.mm | 2 ++ src/darwin/Framework/CHIP/MTRDeviceController_Internal.h | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/src/darwin/Framework/CHIP/MTRDeviceController.mm b/src/darwin/Framework/CHIP/MTRDeviceController.mm index edd521845b2415..4be45cc8415f45 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceController.mm @@ -102,6 +102,8 @@ static NSString * const kErrorSpake2pVerifierSerializationFailed = @"PASE verifier serialization failed"; static NSString * const kErrorCDCertStoreInit = @"Init failure while initializing Certificate Declaration Signing Keys store"; +chip::Tracing::MetricKey kMTRPairingSetup = "pairing-setup-session"; + typedef void (^SyncWorkQueueBlock)(void); typedef id (^SyncWorkQueueBlockWithReturnValue)(void); typedef BOOL (^SyncWorkQueueBlockWithBoolReturnValue)(void); @@ -606,6 +608,8 @@ - (BOOL)setupCommissioningSessionWithPayload:(MTRSetupPayload *)payload newNodeID:(NSNumber *)newNodeID error:(NSError * __autoreleasing *)error { + MATTER_LOG_METRIC_BEGIN(kMTRPairingSetup); + auto block = ^BOOL { // Try to get a QR code if possible (because it has a better // discriminator, etc), then fall back to manual code if that fails. diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm index d9104291414aae..73ea786511720d 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm @@ -17,6 +17,7 @@ #import "MTRDeviceControllerDelegateBridge.h" #import "MTRDeviceController.h" +#import "MTRDeviceController_Internal.h" #import "MTRError_Internal.h" #import "MTRLogging_Internal.h" #import "MTRMetricsCollector.h" @@ -117,6 +118,7 @@ void MTRDeviceControllerDelegateBridge::OnCommissioningComplete(chip::NodeId nodeId, CHIP_ERROR error) { MTR_LOG_DEFAULT("DeviceControllerDelegate Commissioning complete. NodeId %llu Status %s", nodeId, chip::ErrorStr(error)); + MATTER_LOG_METRIC_END(kMTRPairingSetup); id strongDelegate = mDelegate; MTRDeviceController * strongController = mController; diff --git a/src/darwin/Framework/CHIP/MTRDeviceController_Internal.h b/src/darwin/Framework/CHIP/MTRDeviceController_Internal.h index b55d41b8d8a59e..0953098cbaba94 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController_Internal.h +++ b/src/darwin/Framework/CHIP/MTRDeviceController_Internal.h @@ -43,6 +43,8 @@ #endif // MTR_PER_CONTROLLER_STORAGE_ENABLED #import +#import + @class MTRDeviceControllerStartupParamsInternal; @class MTRDeviceControllerFactory; @class MTRDevice; @@ -57,6 +59,8 @@ namespace Controller { NS_ASSUME_NONNULL_BEGIN +extern chip::Tracing::MetricKey kMTRPairingSetup; + @interface MTRDeviceController () #if !MTR_PER_CONTROLLER_STORAGE_ENABLED