M-Swift All articles
Testing & Tooling

Crash Logs Don't Fix Themselves: A Weekly MetricKit Triage the Whole Team Can Stomach

M-Swift
Crash Logs Don't Fix Themselves: A Weekly MetricKit Triage the Whole Team Can Stomach

Photo: w_lemay, CC BY-SA 2.0, via Wikimedia Commons

Every team I've talked to in the last year has the same folder. It's called something like Diagnostics/, it lives on somebody's laptop or in a shared drive, and it contains several hundred MetricKit payloads going back to a release nobody remembers shipping. The subscriber is still registered. The files are still arriving. Nobody has opened one since roughly the second week of the quarter.

That's not a discipline problem, it's a shape problem. A MetricKit payload is a wall of nested JSON that describes one device, one OS, one app version, and a call stack tree — and it arrives a day late, silently, in batches. Even a motivated engineer bounces off the second file.

So don't ask for motivation. Ask for a ritual.

Why the pile grows faster than the fixes

A single diagnostic payload can carry crash diagnostics, hang diagnostics, CPU exceptions, disk-write exceptions, and launch diagnostics all at once. On a mid-size app you might get a handful of payloads per day, each one representing a bucket of similar sessions rather than a single event. Twenty minutes of reading gets you two real signals and a lot of noise about a device model you don't test on.

The usual reaction is to build a dashboard. That's the trap — a dashboard is a place where data goes to be looked at occasionally and acted on never. What you actually want is a decision, once a week, with a hard cap on how many decisions you're allowed to make.

The ritual: thirty minutes, Monday, four people

Same time every week. Calendar invite, not a Slack reminder. Four participants is the sweet spot: whoever owns the platform layer, one feature engineer, the release manager, and a rotating "sheriff" who runs the meeting and doesn't need to be technical.

Minute 0–5: collect. The collector job copies everything from MXMetricManager into the shared directory and backfills anything missed with MXMetricManager.shared.pastDiagnosticPayloads. Nobody does this by hand.

Minute 5–15: collapse. Run the script below. Everyone stares at the same sorted table instead of six different terminal windows.

Minute 15–25: cluster. Humans do the part machines are bad at — deciding which rows are the same bug wearing different clothes.

Minute 25–30: assign and cap. Five items. Five names. No more. If the list is longer than five, the extras go into a backlog with a note, not onto this week's plate.

That cap is the whole point. A ritual that produces forty action items is a ritual nobody shows up to twice.

Grouping rules that survive contact with reality

Raw exception type is a terrible grouping key. EXC_BAD_ACCESS tells you nothing about whether it's one bug or fifteen. Group on this instead:

For hangs, don't group by the hang duration. Group by the function that was blocking the main thread — the caller on the main thread where the stack dead-ends is the actual finding. And for launch diagnostics, compare medians against the previous release, not against some absolute number you made up.

The script: flatten it, sort it, count it

This assumes your payloads land as individual .json files. It's jq, not Swift, because jq is already on the machines and this shouldn't turn into a side project.

#!/usr/bin/env bash
# metric-triage.sh — flatten MetricKit crash payloads into one ranked TSV
set -euo pipefail
DIR="${1:-./Diagnostics}"

jq -r '
  def signature:
    [ .callStackTree.callStacks[]?
      | select(.threadAttributed == true)
      | .callStackRootFrames[]?
      | .binaryName ]
    | .[0:3] | join(" <-");

  .crashDiagnostics[]?
  | [ (.diagnosticMetaData.appVersion   // "?"),
      (.diagnosticMetaData.osVersion    // "?"),
      (.diagnosticMetaData.terminationReason // "unknown"),
      signature ]
  | @tsv
' "$DIR"/*.json 2>/dev/null \
  | sort | uniq -c | sort -rn \
  > crash-summary.tsv

head -20 crash-summary.tsv

The output is one line per cluster: count, app version, OS, termination reason, top three frames. Swap crashDiagnostics for hangDiagnostics and change the signature to pull from the main-thread stack, and you get the hang view for free. Same idea for appLaunchDiagnostics — you're just averaging a duration instead of counting clusters.

Keep the script in the repo next to the collector, not in someone's dotfiles. It's a team artifact now.

Owners, or the meeting doesn't count

Every item that leaves the ritual has one name on it. Not a team, not a channel — a person. The sheriff's job is to make sure that happens, and the sheriff is explicitly allowed to say "nobody wants this, so we're closing it with a note" rather than leaving it unassigned. An unassigned bug is a bug with a shelf life.

SDK-owned crashes get a ticket in the vendor's tracker and a line in the report, then they leave the list. OS-owned crashes get a feedback report and a note that they're environmental — annoying, but not something your sprint should absorb.

The one-page report

Five bullets, posted in the same channel every Monday by 10:15 a.m. local time. What's new, what got fixed, what's still open with an owner and a date, what got closed on purpose, and any metric that moved more than a few percent week over week. No charts you have to click through, no dashboard link that nobody opens.

The written record matters more than it sounds. Six weeks in, that channel history becomes your own memory of what you already tried and what it cost you — the thing you'd otherwise reconstruct from a stale ticket thread.

When to bend the rules

Right after a release ships, promote anything that's clearly new in that build and skip the volume threshold entirely. During a code freeze, run the ritual but only to log, not to fix. And if a single crash crosses roughly 1% of sessions, drop the ritual and go fix that one thing — the cap is a tool for normal weeks, not a law of physics.

Otherwise, keep it dull. Dull is what makes it survive a busy Tuesday, a reorg, and the week everyone's on vacation. The payloads aren't going to read themselves, but thirty minutes and one shell script will get you most of the way there.

All Articles

Related Articles

Dress Rehearsal for SwiftData: Testing Schema Changes on Copies of Real User Stores

Dress Rehearsal for SwiftData: Testing Schema Changes on Copies of Real User Stores

Paper Trail, Not Bug Hunt: Preflighting Privacy Manifests in Swift Dependencies

Paper Trail, Not Bug Hunt: Preflighting Privacy Manifests in Swift Dependencies

Simulator Says Yes, iPhone Says Yikes: Seven Device-Only Swift Performance Tests

Simulator Says Yes, iPhone Says Yikes: Seven Device-Only Swift Performance Tests