<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetricKit",
  "identifier" : "/documentation/MetricKit/MetricManager",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "MetricKit"
    ],
    "preciseIdentifier" : "s:9MetricKit0A7ManagerC"
  },
  "title" : "MetricManager"
}
-->

# MetricManager

An object that delivers metric and diagnostic reports to your app.

```
final class MetricManager
```

## Discussion

`MetricManager` is an instantiable class rather than a shared singleton. Create an instance and hold it for as long as you need reports. Share that instance across your app rather than creating multiple instances with the same domains. If you create more than one `MetricManager`, two tasks concurrently iterating the same sequence both receive a non-deterministic subset of reports rather than a full copy.

Metric reports arrive through [`metricReports`](/documentation/MetricKit/MetricManager/metricReports), and diagnostic reports through [`diagnosticReports`](/documentation/MetricKit/MetricManager/diagnosticReports). Both are typed `AsyncSequence` properties that never throw, so you iterate them with `for await` in long-lived tasks:

```swift
let manager = MetricManager()

Task {
    for await report in manager.metricReports {
        process(report)
    }
}
Task {
    for await report in manager.diagnosticReports {
        process(report)
    }
}
```

To receive metrics segmented by app state, pass a set of [`StateReportingDomain`](/documentation/MetricKit/StateReportingDomain) values to [`init(enabledStateReportingDomains:)`](/documentation/MetricKit/MetricManager/init(enabledStateReportingDomains:)). When state reporting is enabled, [`stateEntries`](/documentation/MetricKit/MetricReport/stateEntries) carries metrics grouped by each recorded state in addition to the standard [`intervalEntries`](/documentation/MetricKit/MetricReport/intervalEntries).

## Topics

### Initialization

[`init()`](/documentation/MetricKit/MetricManager/init())

Creates a new `MetricManager` instance without state reporting domains.

[`init(enabledStateReportingDomains:)`](/documentation/MetricKit/MetricManager/init(enabledStateReportingDomains:))

Creates a new `MetricManager` instance with state reporting domains enabled for metrics aggregation.

[`enabledStateReportingDomains`](/documentation/MetricKit/MetricManager/enabledStateReportingDomains)

StateReporting domains enabled for metrics aggregation

### Reports

[`metricReports`](/documentation/MetricKit/MetricManager/metricReports)

An asynchronous sequence that delivers daily metric reports.

[`diagnosticReports`](/documentation/MetricKit/MetricManager/diagnosticReports)

An asynchronous sequence that delivers diagnostic reports as individual events.

### Custom metric logs

[`logHandle(category:)`](/documentation/MetricKit/MetricManager/logHandle(category:))

Returns an `OSLog` handle for creating custom signpost metrics that MetricKit aggregates.

### Extended launch

[`trackLaunchTask(id:onTrackingError:_:)`](/documentation/MetricKit/MetricManager/trackLaunchTask(id:onTrackingError:_:)-48k2s)

Measures the duration of an asynchronous extended launch task.

[`trackLaunchTask(id:onTrackingError:_:)`](/documentation/MetricKit/MetricManager/trackLaunchTask(id:onTrackingError:_:)-jnu1)

Measures the duration of a synchronous extended launch task.

[`LaunchTaskError`](/documentation/MetricKit/MetricManager/LaunchTaskError)

An error that describes a problem that occurred while tracking an extended launch task.

[`LaunchTaskID`](/documentation/MetricKit/LaunchTaskID)

An identifier for a task measured as part of an extended app launch.

### State-contextualized metrics

[`ReportedState`](/documentation/MetricKit/MetricManager/ReportedState)

A recorded app state associated with a metric or diagnostic report entry.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)