Skip to content

MetricKit macOS xcode14.0 beta1

Israel Soto edited this page Aug 4, 2022 · 3 revisions

#MetricKit.framework https://github.com/xamarin/xamarin-macios/pull/15629

diff -ruN /Applications/Xcode_13.3.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MXAppLaunchDiagnostic.h /Applications/Xcode_14.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MXAppLaunchDiagnostic.h
--- /Applications/Xcode_13.3.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MXAppLaunchDiagnostic.h	1969-12-31 19:00:00.000000000 -0500
+++ /Applications/Xcode_14.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MXAppLaunchDiagnostic.h	2022-05-31 15:02:48.000000000 -0400
@@ -0,0 +1,31 @@
+//  Copyright (c) 2022 Apple Inc.
+//  All rights reserved.
+
+#import <Foundation/Foundation.h>
+#import <os/availability.h>
+#import <MetricKit/MXDiagnostic.h>
+#import <MetricKit/MXCallStackTree.h>
+
+
+/*!
+@class         MXAppLaunchDiagnostic
+@abstract      An MXDiagnostic subclass that encapsulates app launch diagnostic reports.
+*/
+API_AVAILABLE(ios(16.0)) API_UNAVAILABLE(macos, tvos, watchos)
+@interface MXAppLaunchDiagnostic : MXDiagnostic
+
+/*!
+@property      callStackTree
+@abstract      The application call stack tree associated with the app launch.
+*/
+@property (readonly, strong, nonnull) MXCallStackTree *callStackTree;
+
+/*!
+@property      launchDuration
+@abstract      Total app launch duration.
+@discussion    Dimensioned as NSUnitDuration.
+*/
+@property (readonly, strong, nonnull) NSMeasurement<NSUnitDuration *> *launchDuration;
+
+@end
+
diff -ruN /Applications/Xcode_13.3.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MXAppLaunchMetric.h /Applications/Xcode_14.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MXAppLaunchMetric.h
--- /Applications/Xcode_13.3.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MXAppLaunchMetric.h	2022-02-23 10:56:29.000000000 -0500
+++ /Applications/Xcode_14.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MXAppLaunchMetric.h	2022-05-31 15:02:47.000000000 -0400
@@ -43,6 +43,14 @@
 */
 @property (readonly, strong, nonnull) MXHistogram<NSUnitDuration *> *histogrammedOptimizedTimeToFirstDraw API_AVAILABLE(ios(15.2)) API_UNAVAILABLE(macos, tvos, watchos);
 
+/*!
+ @property      histogrammedExtendedLaunch
+ @abstract      Histogrammed extended launch data.
+ @discussion    Dimensioned as NSUnitDuration.
+ @discussion    This represents the time when the app has drawn the first frame and finishes all extended launch tasks that assigned by the developer.
+*/
+@property (readonly, strong, nonnull) MXHistogram<NSUnitDuration *> *histogrammedExtendedLaunch API_AVAILABLE(ios(16.0)) API_UNAVAILABLE(macos, tvos, watchos);
+
 @end
 
 NS_ASSUME_NONNULL_END
diff -ruN /Applications/Xcode_13.3.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MXDiagnosticPayload.h /Applications/Xcode_14.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MXDiagnosticPayload.h
--- /Applications/Xcode_13.3.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MXDiagnosticPayload.h	2022-02-23 10:56:29.000000000 -0500
+++ /Applications/Xcode_14.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MXDiagnosticPayload.h	2022-05-31 15:02:47.000000000 -0400
@@ -12,6 +12,7 @@
 #import <MetricKit/MXCPUExceptionDiagnostic.h>
 #import <MetricKit/MXDiskWriteExceptionDiagnostic.h>
 #import <MetricKit/MXHangDiagnostic.h>
+#import <MetricKit/MXAppLaunchDiagnostic.h>
 #import <MetricKit/MXCrashDiagnostic.h>
 
 NS_ASSUME_NONNULL_BEGIN
@@ -47,6 +48,12 @@
 @property (readonly, strong, nullable) NSArray<MXHangDiagnostic *> *hangDiagnostics;
 
 /*!
+@property      appLaunchDiagnostics
+@abstract      An array containing app launch diagnostics for this application.
+*/
+@property (readonly, strong, nullable) NSArray<MXAppLaunchDiagnostic *> *appLaunchDiagnostics API_AVAILABLE(ios(16.0)) API_UNAVAILABLE(macos, tvos, watchos);
+
+/*!
 @property      crashDiagnostics
 @abstract      An array containing crash diagnostics for this application.
 */
diff -ruN /Applications/Xcode_13.3.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MXError.h /Applications/Xcode_14.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MXError.h
--- /Applications/Xcode_13.3.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MXError.h	1969-12-31 19:00:00.000000000 -0500
+++ /Applications/Xcode_14.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MXError.h	2022-05-31 15:02:47.000000000 -0400
@@ -0,0 +1,36 @@
+//
+//  MXError.h
+//  MetricKit
+//
+//  Copyright (c) 2022 Apple Inc.
+//  All rights reserved.
+
+#import <Foundation/Foundation.h>
+
+/*!
+    @const      MXErrorDomain
+    @abstract   Error domain for NSError values stemming from the MetricKit Framework API.
+    @discussion This error domain is used as the domain for all NSError instances stemming from the MetricKit Framework.
+*/
+extern NSErrorDomain const MXErrorDomain API_AVAILABLE(ios(16.0)) API_UNAVAILABLE(macos, tvos, watchos);
+
+/*!
+    @enum       MXErrorCode
+    @abstract   Error codes for NSError values stemming from the MetricKit Framework.
+    @discussion These error codes are used as the codes for all NSError instances stemmming from the MetricKit Framework.
+ 
+    @constant   MXErrorLaunchTaskInvalidID           The passed-in task ID is a null value or exceeds the max 128 character length.
+    @constant   MXErrorLaunchTaskMaxCount            Exceeded the max number of tasks.
+    @constant   MXErrorLaunchTaskPastDeadline        The start call was made too late, see @discussion.
+    @constant   MXErrorLaunchTaskDuplicated          A task with the same ID has already been started.
+    @constant   MXErrorLaunchTaskUnknown             The task hasn't been started or has already been finished.
+    @constant   MXErrorLaunchTaskInternalFailure     Internal failures happened inside of MetricKit.
+*/
+typedef NS_ERROR_ENUM(MXErrorDomain, MXErrorCode) {
+    MXErrorLaunchTaskInvalidID,
+    MXErrorLaunchTaskMaxCount,
+    MXErrorLaunchTaskPastDeadline,
+    MXErrorLaunchTaskDuplicated,
+    MXErrorLaunchTaskUnknown,
+    MXErrorLaunchTaskInternalFailure
+} API_AVAILABLE(ios(16.0)) API_UNAVAILABLE(macos, tvos, watchos);
diff -ruN /Applications/Xcode_13.3.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MXMetricManager.h /Applications/Xcode_14.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MXMetricManager.h
--- /Applications/Xcode_13.3.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MXMetricManager.h	2022-02-23 07:59:12.000000000 -0500
+++ /Applications/Xcode_14.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MXMetricManager.h	2022-06-03 18:09:13.000000000 -0400
@@ -16,6 +16,13 @@
 @protocol MXMetricManagerSubscriber;
 
 /*!
+ @typedef       MXLaunchTaskID
+ @abstract      Describes the general purpose of a specific launch task.
+ */
+API_AVAILABLE(ios(16.0)) API_UNAVAILABLE(macos, tvos, watchos)
+typedef const NSString *const MXLaunchTaskID NS_TYPED_EXTENSIBLE_ENUM;
+
+/*!
  @class         MXMetricManager
  @abstract      An instance of this class can be used to retrieve periodic, aggregated power and performance metrics.
  @discussion    To receive metrics, clients must acquire a reference to the shared instance of the metric manager and add an eligible MXMetricManagerSubscriber.
@@ -68,6 +75,31 @@
  */
 - (void)removeSubscriber:(id<MXMetricManagerSubscriber>)subscriber;
 
+/*!
+ @method        extendLaunchMeasurementForTaskID:error:
+ @abstract      Start measuring an extended launch task with the given task id.
+ @discussion    This method tracks extra setup tasks required to make the application perceived as fully launched, such as loading up content from the disk or refreshing data from the network, rendering images, etc.
+ @discussion    Each task needs to start before or during @c UISceneDelegate.scene(_:restoreInteractionStateWith:) or before @c UISceneDelegate.sceneDidBecomeActive(_:) is called on the first scene to connect. For example, at the time @c UIApplicationDelegate.application(_:didFinishLaunchingWithOptions:) is called.
+ @discussion    The maximum number of tasks is 16.
+ @discussion    This method needs to be called on the main thread.
+ @param         taskID              The task identifier. Must be an unique nonnull custom string.
+ @param         error               If an error occurs, this will contain a valid @c NSError object on exit.
+ @result        Returns @c YES if the measurement started successfully and @c NO otherwise.
+ */
+
++ (BOOL)extendLaunchMeasurementForTaskID:(MXLaunchTaskID)taskID error:(NSError **)error API_AVAILABLE(ios(16.0)) API_UNAVAILABLE(macos, tvos, watchos);
+
+/*!
+ @method        finishExtendedLaunchMeasurementForTaskID:error:
+ @abstract      Signal the end of an extended launch task previously started with @c extendLaunchMeasurementForTaskID:error: .
+ @discussion    This method needs to be called on the main thread.
+ @param         taskID              The task identifier. Must match the task identifier passed to @c extendLaunchMeasurementForTaskID:error: .
+ @param         error               If an error occurs, this will contain a valid @c NSError object on exit.
+ @result        Returns @c YES if the measurement for the task finished successfully and @c NO otherwise.
+ */
+
++ (BOOL)finishExtendedLaunchMeasurementForTaskID:(MXLaunchTaskID)taskID error:(NSError **)error API_AVAILABLE(ios(16.0)) API_UNAVAILABLE(macos, tvos, watchos);
+
 @end
 
 /*!
diff -ruN /Applications/Xcode_13.3.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MetricKit.h /Applications/Xcode_14.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MetricKit.h
--- /Applications/Xcode_13.3.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MetricKit.h	2022-02-12 07:00:56.000000000 -0500
+++ /Applications/Xcode_14.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetricKit.framework/Headers/MetricKit.h	2022-05-21 20:10:47.000000000 -0400
@@ -33,4 +33,6 @@
 #import <MetricKit/MXDiskWriteExceptionDiagnostic.h>
 #import <MetricKit/MXHangDiagnostic.h>
 #import <MetricKit/MXCrashDiagnostic.h>
+#import <MetricKit/MXAppLaunchDiagnostic.h>
 #import <MetricKit/MXAppExitMetric.h>
+#import <MetricKit/MXError.h>
Clone this wiki locally