MetricReport
A daily performance report that contains metric values for your app.
Declaration
struct MetricReportMentioned in
Discussion
MetricReport is a value type that conforms to Sendable and Codable, so you can pass it across actor boundaries and serialize it with JSONEncoder directly.
Each report covers a 24-hour reporting period. Access metric data through intervalEntries, which contains one or more MetricReport.IntervalEntry values. Use the MetricReport.IntervalEntry collection’s fullDayEntry property to retrieve the full-day aggregate, then iterate its values array and switch over each MetricResult:
if let entry = report.intervalEntries.fullDayEntry {
for result in entry.values {
switch result {
case .cpuTime(let metric):
record(metric)
case .peakMemory(let metric):
record(metric)
@unknown default:
break
}
}
}When state reporting is enabled via init(enabledStateReportingDomains:), the report also populates stateEntries with MetricResult values scoped to each recorded app state. Only a subset of metric types appear in state entries, including hang time, hitch time, app termination counts, signpost intervals, and app runtime metrics. Metrics such as CPU time, memory, network, disk I/O, GPU, app launch, and disk space appear only in intervalEntries.