Swift6/trace#2876
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0c2050da1e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| public protocol OTTracer { | ||
| typealias TagValue = Encodable & Sendable |
There was a problem hiding this comment.
Preserve Encodable-only tag call sites
Changing TagValue from the previous Encodable shape to Encodable & Sendable is a source-breaking public API change for existing apps that keep tags in [String: Encodable] variables or use custom Encodable tag types that have not declared Sendable; those call sites no longer type-check when passed to Trace.Configuration(tags:), startSpan(... tags:), or setTag. Since this is a trace Swift 6 migration rather than a major API redesign, consider preserving the old public signature and handling sendability internally (for example with preconcurrency/unchecked wrappers) so existing customers do not have to change tag model declarations just to upgrade.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This works exactly as intended. In Swift 5 projects that import the SDK, the setTag API can be called with non-sendable entities. In Swift 6 projects, entities must be Sendable. This is exactly the point of Swift 6, enforcing safe concurrency and prevent data races at compile time. Passing a non-sendable entity to this API in a Swift 6 project is an error that should prevent the project from being built, otherwise harder to debug problems will occur, since Tags are passed around between threads.
Since OpenTelemetryApi is also going under upgrade to Swift 6, that dependency was temporarily switched from the Carthage pre-built package to SPM pointing to a specific commit. This will be reverted later.
Still a lot of cleanup and improvements to be done, this is a checkpoint.
As with Xcode project files, it was set to temporarily using the opentelemetry repo main branch, which included patches for Swift 6.
…up to date with Swift 6.
`@preconcorrency` had to be used here since DatadogCore is not yet Sendable, but the usage in this situation is safe (it's only used to call `send(message…)`).
What and why?
Migrates
DatadogTraceto Swift 6.How?
As part of the Swift 6 migration strategy, this patch makes many entities
Sendableso users don't need to import packages as@preconcurrency. The Open Telemetry dependency was updated to the newest version with Swift 6 support as well.Review checklist
make api-surfacewhen adding new APIs