MetricKit

This feature, once enabled, subscribes to MXDiagnosticPayload data of MetricKit and it to Sentry.

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
}

You can enable enableMetricKitRawPayload to view the raw MetricKit diagnostic payload in JSON format as an attachment on the converted event in Sentry. This feature is available on Cocoa 8.29.0 and up.

Copied
import Sentry

SentrySDK.start { options in
    options.dsn = "https://examplePublicKey@o0.ingest.sentry.io/0"
    options.enableMetricKit = true
    options.enableMetricKitRawPayload = 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").