# Apple SDK: Symbolicated flame graphs for MetricKit hangs

Published: 2026-11-30

Source: https://sentry.io/changelog/apple-sdk-metrickit-hang-flame-graphs

---

MetricKit hang flame graph attachments are now available to everyone using Sentry Apple SDK **[9.31.0](https://github.com/getsentry/sentry-cocoa/releases/tag/9.31.0)** or later on iOS 15 and later and macOS 12 and later. See the call paths sampled by Apple's operating system while your app was unresponsive, symbolicated with your app's debug symbols.

A single stack trace captures only one moment of a hang. A flame graph lets you explore multiple sampled paths, such as decoding a response, calculating totals, and encoding a receipt. The SDK now sends the sampled call tree as a separate `flamegraph.json` attachment, preserving branches that ordinary event stack trace limits could otherwise remove.

Sentry also selects a representative stack trace for issue grouping, considering sample counts, stack depth, and in-app frames. Start there, then explore the graph for more context. The selection is a best-effort heuristic, not proof of the cause or a guarantee that related hangs will group together.

## Try it in your app

The opt-in configuration is experimental and may change in a future release. Add these options to your existing SDK initialization:

```swift
import Sentry

SentrySDK.start { options in
    options.dsn = "___PUBLIC_DSN___"
    options.enableMetricKit = true
    options.experimental.metrickit.hangReportingMode = .flamegraphAttachment
}
```

This enables MetricKit's hang, CPU, and disk-write diagnostics. To capture only hang diagnostics in Swift with SDK **[9.32.0](https://github.com/getsentry/sentry-cocoa/releases/tag/9.32.0)** or later, replace `options.enableMetricKit = true` with `options.experimental.metrickit.enabledDiagnosticReports = [.hang]`.

MetricKit diagnostics are independent of [App Hang tracking](https://docs.sentry.io/platforms/apple/configuration/app-hangs/), and `appHangTimeoutInterval` does not change MetricKit's detection threshold.

Upload matching [debug symbols](https://docs.sentry.io/platforms/apple/dsym/). Tracing and profiling do not need to be enabled. Hang events consume error-event quota, and flame graphs consume attachment quota, not profiling quota.

## Investigate a hang

Find reports in Issues with `error.mechanism:mx_hang_diagnostic`. Open an event to inspect its representative stack trace.

![Representative stack trace for a sample-app MetricKit hang event, showing the mx_hang_diagnostic mechanism and product decoding on the main thread.](/img/changelog/2026-11-metrickit-hang-stack-trace.webp)

Then open the **Flamegraph** section to explore sampled branches outside that stack trace. If it contains multiple call trees, use the tree selector to explore each one.

![Sample-app MetricKit flame graph showing checkout paths through product decoding, price calculations, and receipt encoding, with the flamegraph.json attachment below.](/img/changelog/2026-11-metrickit-hang-flamegraph.webp)

Start with a wider application frame and inspect the calls beneath it. **Width represents sample count**, including samples in descendants, not exact duration. Horizontal position is not execution order, and some trees aggregate observations across threads. Use these observations to form a debugging hypothesis, then validate it with local performance tooling.

Each attachment is limited to **10 MiB**, with symbolication of up to the first **2,500 frame entries**. Additional frames stay in the graph but may be unresolved. If the SDK cannot create the attachment, it falls back to legacy stack trace reporting.

Read the [MetricKit documentation](https://docs.sentry.io/platforms/apple/configuration/metric-kit/) for configuration, reporting behavior, and attachment limits, or follow the [cookbook recipe](https://sentry.io/cookbook/debug-ios-hangs-with-metrickit/) for a step-by-step investigation.