MetricKit

The MetricKit integration subscribes to MXHangDiagnostic, MXDiskWriteExceptionDiagnostic and MXCPUExceptionDiagnostic, which it converts to Sentry events.

This feature is available on Cocoa 8.14.0 and up. The SDK supports this feature from iOS 15 and up and macOS 12 and up because in these versions, MetricKit delivers diagnostic reports immediately, which allows the Sentry SDK to apply current data from the scope.

Note that the Cocoa SDK has no control over the stack traces provided by MetricKit. Some only offer a couple of frames. If these aren't useful to you, you can drop them in beforeSend.

You can identify MetricKit events by looking at the mx_hang_diagnostic, mx_cpu_exception, and mx_disk_write_exception mechanism.type.

Enable this feature by setting the enableMetricKit option to true:

Copied
import Sentry

SentrySDK.start { options in
    options.dsn = "https://examplePublicKey@o0.ingest.sentry.io/0"
    options.enableMetricKit = true
}
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").