---
title: "withIntervalSignpost(_:id:_:around:)"
framework: os
role: symbol
role_heading: Instance Method
path: "os/ossignposter/withintervalsignpost(_:id:_:around:)"
---

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

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

## Declaration

```swift
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 doc://com.apple.os/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 doc://com.apple.os/documentation/os/message-argument-formatters.
- `task`: The closure around which to create the signposted interval.

## Discussion

Discussion important: Don’t create an instance of 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 as the id parameter. Otherwise, use the makeSignpostID() and makeSignpostID(from:) methods to generate a signpost identifier, as the following example shows: 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() }

## See Also

### Measuring a Closure

- [withIntervalSignpost(_:id:around:)](os/ossignposter/withintervalsignpost(_:id:around:).md)
