Skip to content

Swift6/trace#2876

Draft
arroz wants to merge 13 commits into
developfrom
swift6/trace
Draft

Swift6/trace#2876
arroz wants to merge 13 commits into
developfrom
swift6/trace

Conversation

@arroz
Copy link
Copy Markdown
Contributor

@arroz arroz commented May 4, 2026

What and why?

Migrates DatadogTrace to Swift 6.

How?

As part of the Swift 6 migration strategy, this patch makes many entities Sendable so 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

  • Feature or bugfix MUST have appropriate tests (unit, integration)
  • Make sure each commit and the PR mention the Issue number or JIRA reference
  • Add CHANGELOG entry for user facing changes
  • Add Objective-C interface for public APIs - see our guidelines (internal)
  • Run make api-surface when adding new APIs

@arroz arroz marked this pull request as ready for review May 14, 2026 13:20
@arroz arroz requested review from a team as code owners May 14, 2026 13:20
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread Package.swift Outdated
Comment on lines +8 to +9
public protocol OTTracer {
typealias TagValue = Encodable & Sendable
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@arroz arroz marked this pull request as draft May 14, 2026 14:27
arroz added 13 commits May 15, 2026 16:37
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.
`@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…)`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant