<!--
{
  "availability" : [
    "iOS: 10.0.0 - 13.0.0",
    "iPadOS: 10.0.0 - 13.0.0",
    "macCatalyst: 13.1.0 - 13.1.0",
    "macOS: 10.12.0 - 10.15.0",
    "tvOS: 10.0.0 - 13.0.0",
    "visionOS: 1.0.0 - 1.0.0",
    "watchOS: 3.0.0 - 6.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLSessionTaskMetrics/init()",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSURLSessionTaskMetrics(im)init"
  },
  "title" : "init()"
}
-->

# init()

Creates a task metrics instance.

```
init()
```

## Discussion

You should never need to create your own [`URLSessionTaskMetrics`](/documentation/Foundation/URLSessionTaskMetrics) instances. If you are interested in task metrics, implement the [`urlSession(_:task:didFinishCollecting:)`](/documentation/Foundation/URLSessionTaskDelegate/urlSession(_:task:didFinishCollecting:)) method of [`URLSessionTaskDelegate`](/documentation/Foundation/URLSessionTaskDelegate). The [`URLSession`](/documentation/Foundation/URLSession) will collect task metrics for you and deliver them to this method.

---

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)