Skip to content

Commit

Permalink
Sample code of how Begin and End log metrics can be used
Browse files Browse the repository at this point in the history
  • Loading branch information
anush-apple committed Feb 22, 2024
1 parent 5cb87a9 commit 4ea7122
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/darwin/Framework/CHIP/MTRDeviceController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<MTRDeviceControllerDelegate> strongDelegate = mDelegate;
MTRDeviceController * strongController = mController;
Expand Down
4 changes: 4 additions & 0 deletions src/darwin/Framework/CHIP/MTRDeviceController_Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED
#import <Matter/MTROTAProviderDelegate.h>

#import <tracing/metric_event.h>

@class MTRDeviceControllerStartupParamsInternal;
@class MTRDeviceControllerFactory;
@class MTRDevice;
Expand All @@ -57,6 +59,8 @@ namespace Controller {

NS_ASSUME_NONNULL_BEGIN

extern chip::Tracing::MetricKey kMTRPairingSetup;

@interface MTRDeviceController ()

#if !MTR_PER_CONTROLLER_STORAGE_ENABLED
Expand Down

0 comments on commit 4ea7122

Please sign in to comment.