<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetricKit",
  "identifier" : "/documentation/MetricKit/TotalForegroundTimeMetric",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "MetricKit"
    ],
    "preciseIdentifier" : "s:9MetricKit019TotalForegroundTimeA0V"
  },
  "title" : "TotalForegroundTimeMetric"
}
-->

# TotalForegroundTimeMetric

A metric that measures the total time the app spent in the foreground.

```
struct TotalForegroundTimeMetric
```

## Discussion

This metric corresponds to the [`MetricResult.totalForegroundTime(_:)`](/documentation/MetricKit/MetricResult/totalForegroundTime(_:)) case. It appears in both [`intervalEntries`](/documentation/MetricKit/MetricReport/intervalEntries) and [`stateEntries`](/documentation/MetricKit/MetricReport/stateEntries) when state reporting is enabled.

## Topics

### Measurements

[`let value: Measurement<UnitDuration>`](/documentation/MetricKit/TotalForegroundTimeMetric/value)

The total time the app is in the foreground.

## Relationships

### Conforms To

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

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

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

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

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

[`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)