<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "os",
  "identifier" : "/documentation/os/OSSignposter/withIntervalSignpost(_:id:_:around:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "os"
    ],
    "preciseIdentifier" : "s:2os12OSSignposterV20withIntervalSignpost_2id_6aroundxs12StaticStringV_AA12OSSignpostIDVAA12OSLogMessageVxyKXEtKlF"
  },
  "title" : "withIntervalSignpost(_:id:_:around:)"
}
-->

# withIntervalSignpost(_:id:_:around:)

Measures the execution of a closure and attaches the specified message.

```
func withIntervalSignpost<T>(_ name: StaticString, id: OSSignpostID = .exclusive, _ message: SignpostMetadata, around task: () throws -> T) rethrows -> T
```

## Parameters

`name`

The signpost’s name.

`id`

The signpost’s ID. The default value is [`exclusive`](/documentation/os/OSSignpostID/exclusive).

`message`

The interpolated string that the signposter attaches to the signpost. Each of the message’s interpolations can specify individual formatting and privacy options. For more information, see [Message Argument Formatters](/documentation/os/message-argument-formatters).

`task`

The closure around which to create the signposted interval.

## Discussion

> Important:
> Don’t create an instance of ``doc://com.apple.os/documentation/os/SignpostMetadata``. Instead, provide an interpolated string as the `message` parameter and the system converts it automatically.

The signposter uses a signpost ID to pair the beginning and the end of a signposted interval, which is necessary because multiple intervals with the same configuration and scope can be in-flight simultaneously. If only one interval with a specific configuration can execute at any particular time, pass [`exclusive`](/documentation/os/OSSignpostID/exclusive) as the `id` parameter. Otherwise, use the [`makeSignpostID()`](/documentation/os/OSSignposter/makeSignpostID()) and [`makeSignpostID(from:)`](/documentation/os/OSSignposter/makeSignpostID(from:)) methods to generate a signpost identifier, as the following example shows:

```swift
let accountNumber = "12345678"
                
// Create a signposter using the default subsystem.
let signposter = OSSignposter()
        
// Generate a signpost ID to associate with the signpost.
let signpostID = signposter.makeSignpostID()
        
// Signpost the interval of a closure that encapsulates
// one or more related tasks, and attach a message that
// securely interpolates sensitive data.
signposter.withIntervalSignpost("Account Reconciliation", id: signpostID,
    "Account: \(accountNumber, privacy: .sensitive(mask: .hash))") {
    
    // Perform the related tasks.
    processTransactions()
    updateBalance()
}
```

---

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)