Can MetricKit reliably report CPU, memory, and energy metrics for Network Extension providers?

I'm developing an iOS app that includes the following Network Extension providers:

  • NEPacketTunnelProvider
  • NEFilterDataProvider
  • NEFilterControlProvider

I want to analyze CPU usage, memory footprint, and battery/energy impact for these extensions after release, using data collected from production devices.

I've been looking into MetricKit, including MXMetricManager and MXMetricPayload, and would appreciate clarification on its support for app extensions.

Specifically:

  1. API support: Can MetricKit be initialized and registered as a subscriber from within a Network Extension provider's process? Are there any restrictions specific to these extension types?

  2. Metric availability: If registration is supported, do the resulting metric payloads contain CPU, memory, and energy metrics attributable to the extension itself, or do they cover only the containing app?

  3. Production reliability: Can I rely on MetricKit to collect these metrics consistently across production devices and app versions? Are reports generated for extensions independently, and are there known limitations in report delivery or coverage?

  4. Memory and CPU: Is there a supported way to obtain the extension's peak memory footprint and CPU consumption through MetricKit? If these metrics aren't available through MetricKit, what APIs or reporting mechanisms does Apple recommend?

  5. Energy and battery: Can MetricKit provide energy-impact metrics specifically attributable to a Network Extension provider, rather than aggregated metrics for the containing app?

  6. Recommended approach: For post-release analysis of these extensions, should I use MetricKit, Xcode Organizer's Energy reports, custom telemetry within the extension, or a combination of these?

My goal is to monitor resource consumption and identify regressions in production without relying on Instruments profiling on individual devices.

I'd appreciate clarification on which of these capabilities are officially supported for Network Extension providers and which approach Apple recommends for reliable production monitoring.

Thanks!

Answered by DTS Engineer in 911999022

My understanding, based on bugs in the referenced threads, is that:

Having said that, I’ve not actually tried this from an NE appexen since this support was added in iOS 17, so you should give it a whirl and see what happens.

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

My understanding, based on bugs in the referenced threads, is that:

Having said that, I’ve not actually tried this from an NE appexen since this support was added in iOS 17, so you should give it a whirl and see what happens.

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"