Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ jobs:
name: Unit tests
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
with:
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_6_1_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_6_2_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
windows_6_0_enabled: true
windows_6_1_enabled: true
windows_6_2_enabled: true
windows_nightly_next_enabled: true
windows_nightly_main_enabled: true
windows_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
windows_6_1_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
windows_6_2_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
windows_nightly_next_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"

Expand Down
22 changes: 3 additions & 19 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,19 @@ jobs:
name: Unit tests
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
with:

# NOTE: Aug 5, 2025. We've determined SPM has bugs for `condition: .when(platforms: [.somePlatform])`
# that incorrectly ignore the condition and import anyways for unintended platforms.
#
# See https://github.com/apple/swift-distributed-tracing/actions/runs/16578688393/job/46920025183?pr=174
# for an example of the resulting build failure.
#
# This is documented as a bug in Swift 5.10, resolved in Swift 6.
# See FB14859516.
# See also https://forums.swift.org/t/do-swiftpm-conditional-target-dependencies-work/74047
#
# Given this, the explicit target dependency check is disabled for Swift versions before Swift 6.

# Intentionally disabled:
#
# linux_5_9_arguments_override: "--explicit-target-dependency-import-check error"
# linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"

linux_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_6_1_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_6_2_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
windows_6_0_enabled: true
windows_6_1_enabled: true
windows_6_2_enabled: true
windows_nightly_next_enabled: true
windows_nightly_main_enabled: true
windows_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
windows_6_1_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
windows_6_2_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
windows_nightly_next_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"

Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.9
// swift-tools-version:6.0
import PackageDescription

let package = Package(
Expand Down
12 changes: 0 additions & 12 deletions Sources/Tracing/Tracer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ public func withSpan<T>(
/// - operation: The operation that this span measures.
/// - Returns: the value returned by `operation`.
/// - Throws: the error the `operation` throws (if any).
#if compiler(>=6.0)
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext
public func withSpan<T, Instant: TracerInstant>(
_ operationName: String,
Expand All @@ -346,11 +345,8 @@ public func withSpan<T, Instant: TracerInstant>(
try await operation(anySpan)
}
}
#endif

#if compiler(>=6.0)
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
#endif
/// Start a new span and automatically end when the operation completes,
/// including recording the error in case the operation throws.
///
Expand Down Expand Up @@ -413,7 +409,6 @@ public func withSpan<T, Instant: TracerInstant>(
/// - operation: The operation that this span measures.
/// - Returns: the value returned by `operation`.
/// - Throws: the error the `operation` throws (if any).
#if compiler(>=6.0)
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext
public func withSpan<T>(
_ operationName: String,
Expand All @@ -437,11 +432,8 @@ public func withSpan<T>(
try await operation(anySpan)
}
}
#endif

#if compiler(>=6.0)
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
#endif
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext
/// Start a new span and automatically end when the operation completes,
/// including recording the error in case the operation throws.
Expand Down Expand Up @@ -502,7 +494,6 @@ public func withSpan<T>(
/// - operation: The operation that this span should be measuring
/// - Returns: the value returned by `operation`
/// - Throws: the error the `operation` has thrown (if any)
#if compiler(>=6.0)
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func withSpan<T>(
_ operationName: String,
Expand All @@ -527,11 +518,8 @@ public func withSpan<T>(
try await operation(anySpan)
}
}
#endif

#if compiler(>=6.0)
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
#endif
/// Start a new span and automatically end when the operation completes,
/// including recording the error in case the operation throws.
///
Expand Down
13 changes: 1 addition & 12 deletions Sources/Tracing/TracerProtocol+Legacy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ extension LegacyTracer {
///
/// - Parameters:
/// - operationName: The name of the operation being traced. This may be a handler function, a database call, and so on.
/// - instant: the time instant at which the span started.
/// - context: The `ServiceContext` providing information on where to start the new ``Span``.
/// - kind: The ``SpanKind`` of the new ``Span``.
/// - isolation: Defaulted parameter for inheriting isolation of calling actor.
Expand All @@ -305,7 +306,6 @@ extension LegacyTracer {
/// - operation: The operation that this span measures.
/// - Returns: the value returned by `operation`.
/// - Throws: the error the `operation` throws (if any).
#if compiler(>=6.0)
public func withAnySpan<T, Instant: TracerInstant>(
_ operationName: String,
at instant: @autoclosure () -> Instant,
Expand Down Expand Up @@ -336,12 +336,9 @@ extension LegacyTracer {
throw error // rethrow
}
}
#endif

#if compiler(>=6.0)
// swift-format-ignore: Spacing // fights with formatter
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
#endif
/// Start a new span and automatically end when the operation completes,
/// including recording the error in case the operation throws.
///
Expand Down Expand Up @@ -411,7 +408,6 @@ extension LegacyTracer {
/// - operation: The operation that this span measures.
/// - Returns: the value returned by `operation`.
/// - Throws: the error the `operation` throws (if any).
#if compiler(>=6.0)
public func withAnySpan<T>(
_ operationName: String,
context: @autoclosure () -> ServiceContext = .current ?? .topLevel,
Expand Down Expand Up @@ -441,12 +437,9 @@ extension LegacyTracer {
throw error // rethrow
}
}
#endif

#if compiler(>=6.0)
// swift-format-ignore: Spacing // fights with formatter
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
#endif
/// Start a new span and automatically end when the operation completes,
/// including recording the error in case the operation throws.
///
Expand Down Expand Up @@ -629,7 +622,6 @@ extension Tracer {
/// - operation: The operation that this span measures.
/// - Returns: the value returned by `operation`.
/// - Throws: the error the `operation` throws (if any).
#if compiler(>=6.0)
public func withAnySpan<T>(
_ operationName: String,
at instant: @autoclosure () -> some TracerInstant = DefaultTracerClock.now,
Expand All @@ -653,12 +645,9 @@ extension Tracer {
try await operation(span)
}
}
#endif

#if compiler(>=6.0)
// swift-format-ignore: Spacing // fights with formatter
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
#endif
/// Start a new span and automatically end when the operation completes,
/// including recording the error in case the operation throws.
///
Expand Down
9 changes: 0 additions & 9 deletions Sources/Tracing/TracerProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,13 @@ extension Tracer {
/// - operationName: The name of the operation being traced. This may be a handler function, a database call, and so on.
/// - context: The `ServiceContext` providing information on where to start the new ``Span``.
/// - kind: The ``SpanKind`` of the new ``Span``.
/// - instant: the time instant at which the span started.
/// - isolation: Defaulted parameter for inheriting isolation of calling actor.
/// - function: The function name in which the span started.
/// - fileID: The `fileID` where the span started.
/// - line: The file line where the span started.
/// - operation: The operation that this span measures.
/// - Returns: the value returned by `operation`.
/// - Throws: the error the `operation` throws (if any).
#if compiler(>=6.0)
public func withSpan<T>(
_ operationName: String,
context: @autoclosure () -> ServiceContext = .current ?? .topLevel,
Expand Down Expand Up @@ -289,12 +287,9 @@ extension Tracer {
throw error // rethrow
}
}
#endif

#if compiler(>=6.0)
// swift-format-ignore: Spacing // fights with formatter
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
#endif
public func withSpan<T>(
_ operationName: String,
context: @autoclosure () -> ServiceContext = .current ?? .topLevel,
Expand Down Expand Up @@ -347,7 +342,6 @@ extension Tracer {
/// - operation: The operation that this span measures.
/// - Returns: the value returned by `operation`.
/// - Throws: the error the `operation` throws (if any).
#if compiler(>=6.0)
public func withSpan<T>(
_ operationName: String,
context: @autoclosure () -> ServiceContext = .current ?? .topLevel,
Expand Down Expand Up @@ -378,12 +372,9 @@ extension Tracer {
throw error // rethrow
}
}
#endif

#if compiler(>=6.0)
// swift-format-ignore: Spacing // fights with formatter
@_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API")
#endif
/// Start a new span and automatically end it when the operation completes,
/// including recording the error in case the operation throws.
///
Expand Down
4 changes: 0 additions & 4 deletions Tests/TracingTests/DynamicTracepointTracerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ final class DynamicTracepointTestTracer: LegacyTracer {
}

private func shouldRecord(tracepoint: TracepointID) -> Bool {
#if canImport(_Concurrency)
if self.isActive(tracepoint: tracepoint) {
// this tracepoint was specifically activated!
return true
Expand All @@ -193,9 +192,6 @@ final class DynamicTracepointTestTracer: LegacyTracer {
// there is some active trace already, so we should record as well
// TODO: this logic may need to become smarter
return true
#else
return false
#endif
}

func isActive(tracepoint: TracepointID) -> Bool {
Expand Down
8 changes: 0 additions & 8 deletions Tests/TracingTests/TracerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ final class TracerTests: XCTestCase {
}

func testWithSpan_automaticBaggagePropagation_sync() throws {
#if canImport(_Concurrency)
guard #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) else {
throw XCTSkip("Task locals are not supported on this platform.")
}
Expand All @@ -133,11 +132,9 @@ final class TracerTests: XCTestCase {

XCTAssertEqual(value, "world")
XCTAssertTrue(spanEnded)
#endif
}

func testWithSpan_automaticBaggagePropagation_sync_throws() throws {
#if canImport(_Concurrency)
guard #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) else {
throw XCTSkip("Task locals are not supported on this platform.")
}
Expand All @@ -163,11 +160,9 @@ final class TracerTests: XCTestCase {
return
}
XCTFail("Should have thrown")
#endif
}

func testWithSpan_automaticBaggagePropagation_async() throws {
#if canImport(_Concurrency)
guard #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) else {
throw XCTSkip("Task locals are not supported on this platform.")
}
Expand All @@ -194,7 +189,6 @@ final class TracerTests: XCTestCase {
XCTAssertEqual(value, "world")
XCTAssertTrue(spanEnded.withValue { $0 })
}
#endif
}

func testWithSpan_enterFromNonAsyncCode_passBaggage_asyncOperation() throws {
Expand Down Expand Up @@ -321,7 +315,6 @@ final class TracerTests: XCTestCase {
}

func testWithSpan_recordErrorWithAttributes() throws {
#if canImport(_Concurrency)
guard #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) else {
throw XCTSkip("Task locals are not supported on this platform.")
}
Expand All @@ -348,7 +341,6 @@ final class TracerTests: XCTestCase {
XCTAssertEqual(error as! ExampleSpanError, errorToThrow)
let attrs = endedSpan!.recordedErrors.first!.1
XCTAssertEqual(attrs, attrsForError)
#endif
}

func testWithSpanSignatures() {
Expand Down