func recordAppExitsForeground()

in Sources/apm-agent-ios/Instrumentation/AppMetrics/AppMetrics.swift [237:278]


  func recordAppExitsForeground(metric: MXMetricPayload) {
    if #available(iOS 14.0, *) {
      let appExit = meter.createRawIntCounter(name: ElasticMetrics.appExits.rawValue)
      if let foregroundApplicationExit = metric.applicationExitMetrics?.foregroundExitData {
        appExit.record(sum: foregroundApplicationExit.cumulativeMemoryResourceLimitExitCount,
                       startDate: metric.timeStampBegin,
                       endDate: metric.timeStampEnd,
                       labels: [AppExitStates.key.rawValue: AppExitStates.foreground.rawValue,
                                AppExitValues.key.rawValue: AppExitValues.resourceLimit.rawValue])

        appExit.record(sum: foregroundApplicationExit.cumulativeAppWatchdogExitCount,
                       startDate: metric.timeStampBegin,
                       endDate: metric.timeStampEnd,
                       labels: [AppExitStates.key.rawValue: AppExitStates.foreground.rawValue,
                                AppExitValues.key.rawValue: AppExitValues.watchdog.rawValue])

        appExit.record(sum: foregroundApplicationExit.cumulativeBadAccessExitCount,
                       startDate: metric.timeStampBegin,
                       endDate: metric.timeStampEnd,
                       labels: [AppExitStates.key.rawValue: AppExitStates.foreground.rawValue,
                                AppExitValues.key.rawValue: AppExitValues.badAccess.rawValue])

        appExit.record(sum: foregroundApplicationExit.cumulativeAbnormalExitCount,
                       startDate: metric.timeStampBegin,
                       endDate: metric.timeStampEnd,
                       labels: [AppExitStates.key.rawValue: AppExitStates.foreground.rawValue,
                                AppExitValues.key.rawValue: AppExitValues.abnormal.rawValue])

        appExit.record(sum: foregroundApplicationExit.cumulativeIllegalInstructionExitCount,
                       startDate: metric.timeStampBegin,
                       endDate: metric.timeStampEnd,
                       labels: [AppExitStates.key.rawValue: AppExitStates.foreground.rawValue,
                                AppExitValues.key.rawValue: AppExitValues.illegalInstruction.rawValue])

        appExit.record(sum: foregroundApplicationExit.cumulativeNormalAppExitCount,
                       startDate: metric.timeStampBegin,
                       endDate: metric.timeStampEnd,
                       labels: [AppExitStates.key.rawValue: AppExitStates.foreground.rawValue,
                                AppExitValues.key.rawValue: AppExitValues.normal.rawValue])
      }
    }
  }