Are mxSignpost events visible in Xcode Organizer?

480 Views Asked by At

I can wrap some important code (where I want to observe performance change with new App Versions) in

let handle = MXMetricManager.makeLogHandle(category: "Custom Category")
mxSignpost(.begin, log: handle, name: "Custom Event Name")

and

mxSignpost(.end, log: handle, name: "Custom Event Name")

And as far as I understand when I use MXMetricManager.shared.add(someClass) and in MXMetricManagerSubscriber delegate I receive reports every 24 hours, these reports will contain a separate performance sections for the intervals between mxSignpost(.begin) and mxSignpost(.end).

The question:

Can I see these performance separation in Xcode Organizer for "Custom Event Name" or "Custom Category" from the code above?

enter image description here

1

There are 1 best solutions below

4
iUrii On BEST ANSWER

The Metric organizer doesn't have this feature from the doc:

MetricKit goes beyond the metrics shown in the Metrics organizer to include average pixel luminance, cellular network conditions, and durations associated with custom OSSignpost events in your app. https://developer.apple.com/documentation/metrickit/improving_your_app_s_performance.

The only way to get signpost info it's inspecting MXMetricPayload:

import UIKit
import MetricKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        MXMetricManager.shared.add(self)
        return true
    }

    func applicationWillTerminate(_ application: UIApplication) {
        MXMetricManager.shared.remove(self)
    }
}

extension AppDelegate: MXMetricManagerSubscriber {
    func didReceive(_ payloads: [MXMetricPayload]) {
        for payload in payloads {
            if let signpostMetrics = payload.signpostMetrics {
                for metric in signpostMetrics {
                    print(metric.description)
                }
            }
        }
    }
}