Contents

MetricManager

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

Declaration

final class MetricManager

Mentioned in

Discussion

MetricManager is an instantiable class rather than a shared singleton. Create an instance and hold it for as long as you need reports.

Metric reports arrive through metricReports, and diagnostic reports through diagnosticReports. Both are typed AsyncSequence properties that never throw, so you iterate them with for await in long-lived tasks:

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 values to init(enabledStateReportingDomains:). When state reporting is enabled, stateEntries carries metrics grouped by each recorded state in addition to the standard intervalEntries.

This type replaces MXMetricManager.

Topics

Initialization

Reports

Custom metric logs

Extended launch

State-contextualized metrics

See Also

Metric and diagnostic reports