---
title: DiagnosticReport
framework: metrickit
role: symbol
role_heading: Structure
path: metrickit/diagnosticreport
---

# DiagnosticReport

A report describing a single diagnostic event.

## Declaration

```swift
struct DiagnosticReport
```

## Mentioned in

Analyzing app performance with MetricKit Monitoring app performance with MetricKit

## Discussion

Discussion Each iteration of diagnosticReports yields one report. Access the diagnostic event through result, which is a DiagnosticResult enum. Switch over the result to handle each diagnostic type: for await report in manager.diagnosticReports {     switch report.result {     case .crash(let diagnostic):         handleCrash(diagnostic)     case .hang(let diagnostic):         handleHang(diagnostic)     case .cpuException(let diagnostic):         handleCPUException(diagnostic)     case .diskWriteException(let diagnostic):         handleDiskWriteException(diagnostic)     case .appLaunch(let diagnostic):         handleAppLaunchDiagnostic(diagnostic)     @unknown default:         break     } } The environment property contains device and app metadata, states, and any signpostData associated with the event. The states array contains the MetricManager.ReportedState values that are active when the diagnostic event occurs. MetricKit does not generate a DiagnosticReport for every occurrence of a diagnostic event. For example, hang diagnostics are only generated when the device has hang detection enabled or belongs to a sampling group with hang detection active. Because DiagnosticReport conforms to Codable, you can serialize it directly with JSONEncoder.

## Topics

### Report details

- [timeRange](metrickit/diagnosticreport/timerange.md)
- [environment](metrickit/diagnosticreport/environment-swift.property.md)

### Diagnostic event

- [result](metrickit/diagnosticreport/result.md)

### Structures

- [DiagnosticReport.Environment](metrickit/diagnosticreport/environment-swift.struct.md)

## Relationships

### Conforms To

- [Decodable](swift/decodable.md)
- [Encodable](swift/encodable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Metric and diagnostic reports

- [MetricManager](metrickit/metricmanager.md)
- [MetricReport](metrickit/metricreport.md)
