diff --git a/Package.swift b/Package.swift index 5cd1b0f..8bf4bba 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.7 +// swift-tools-version:5.8 import PackageDescription let package = Package( @@ -19,12 +19,26 @@ let package = Package( name: "Instrumentation", dependencies: [ .product(name: "ServiceContextModule", package: "swift-service-context"), + ], + swiftSettings: [ + .enableExperimentalFeature("StrictConcurrency"), + .unsafeFlags([ + "-Xfrontend", "-disable-availability-checking" +// "-enable-experimental-feature IsolatedAny" + ]) ] ), .testTarget( name: "InstrumentationTests", dependencies: [ .target(name: "Instrumentation"), + ], + swiftSettings: [ + .enableExperimentalFeature("StrictConcurrency"), + .unsafeFlags([ + "-Xfrontend", "-disable-availability-checking" +// "-enable-experimental-feature IsolatedAny" + ]) ] ), @@ -35,12 +49,26 @@ let package = Package( name: "Tracing", dependencies: [ .target(name: "Instrumentation"), + ], + swiftSettings: [ + .enableExperimentalFeature("StrictConcurrency"), + .unsafeFlags([ + "-Xfrontend", "-disable-availability-checking" +// "-enable-experimental-feature IsolatedAny" + ]) ] ), .testTarget( name: "TracingTests", dependencies: [ .target(name: "Tracing"), + ], + swiftSettings: [ + .enableExperimentalFeature("StrictConcurrency"), + .unsafeFlags([ + "-Xfrontend", "-disable-availability-checking" +// "-enable-experimental-feature IsolatedAny" + ]) ] ), ] diff --git a/Sources/Tracing/Tracer.swift b/Sources/Tracing/Tracer.swift index 726aa88..623ebc6 100644 --- a/Sources/Tracing/Tracer.swift +++ b/Sources/Tracing/Tracer.swift @@ -330,6 +330,7 @@ public func withSpan( function: String = #function, file fileID: String = #fileID, line: UInt = #line, + isolation: isolated (any Actor)? = #isolation, _ operation: (any Span) async throws -> T ) async rethrows -> T { try await InstrumentationSystem.legacyTracer.withAnySpan( @@ -375,6 +376,7 @@ public func withSpan( function: String = #function, file fileID: String = #fileID, line: UInt = #line, + isolation: isolated (any Actor)? = #isolation, _ operation: (any Span) async throws -> T ) async rethrows -> T { try await InstrumentationSystem.legacyTracer.withAnySpan( @@ -384,7 +386,8 @@ public func withSpan( ofKind: kind, function: function, file: fileID, - line: line + line: line, + isolation: isolation ) { anySpan in try await operation(anySpan) } @@ -422,6 +425,7 @@ public func withSpan( function: String = #function, file fileID: String = #fileID, line: UInt = #line, + isolation: isolated (any Actor)? = #isolation, _ operation: (any Span) async throws -> T ) async rethrows -> T { try await InstrumentationSystem.legacyTracer.withAnySpan( @@ -431,7 +435,8 @@ public func withSpan( ofKind: kind, function: function, file: fileID, - line: line + line: line, + isolation: isolation ) { anySpan in try await operation(anySpan) } diff --git a/Sources/Tracing/TracerProtocol+Legacy.swift b/Sources/Tracing/TracerProtocol+Legacy.swift index 3426cc9..2a26942 100644 --- a/Sources/Tracing/TracerProtocol+Legacy.swift +++ b/Sources/Tracing/TracerProtocol+Legacy.swift @@ -306,6 +306,7 @@ extension LegacyTracer { /// - operation: The operation that this span should be measuring /// - Returns: the value returned by `operation` /// - Throws: the error the `operation` has thrown (if any) + @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for #isolation public func withAnySpan( _ operationName: String, at instant: @autoclosure () -> Instant, @@ -314,6 +315,7 @@ extension LegacyTracer { function: String = #function, file fileID: String = #fileID, line: UInt = #line, + isolation: isolated (any Actor)? = #isolation, _ operation: (any Tracing.Span) async throws -> T ) async rethrows -> T { let span = self.startAnySpan( @@ -360,6 +362,7 @@ extension LegacyTracer { /// - operation: The operation that this span should be measuring /// - Returns: the value returned by `operation` /// - Throws: the error the `operation` has thrown (if any) + @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for #isolation public func withAnySpan( _ operationName: String, context: @autoclosure () -> ServiceContext = .current ?? .topLevel, @@ -367,6 +370,7 @@ extension LegacyTracer { function: String = #function, file fileID: String = #fileID, line: UInt = #line, + isolation: isolated (any Actor)? = #isolation, _ operation: (any Tracing.Span) async throws -> T ) async rethrows -> T { let span = self.startAnySpan( @@ -530,6 +534,7 @@ extension Tracer { /// - operation: The operation that this span should be measuring /// - Returns: the value returned by `operation` /// - Throws: the error the `operation` has thrown (if any) + @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for #isolation public func withAnySpan( _ operationName: String, at instant: @autoclosure () -> some TracerInstant = DefaultTracerClock.now, @@ -538,7 +543,8 @@ extension Tracer { function: String = #function, file fileID: String = #fileID, line: UInt = #line, - @_inheritActorContext @_implicitSelfCapture _ operation: (any Tracing.Span) async throws -> T + isolation: isolated (any Actor)? = #isolation, + _ operation: (any Tracing.Span) async throws -> T ) async rethrows -> T { try await self.withSpan( operationName, @@ -547,7 +553,8 @@ extension Tracer { at: instant(), function: function, file: fileID, - line: line + line: line, + isolation: isolation ) { span in try await operation(span) } diff --git a/Sources/Tracing/TracerProtocol.swift b/Sources/Tracing/TracerProtocol.swift index 0a0a13d..de08489 100644 --- a/Sources/Tracing/TracerProtocol.swift +++ b/Sources/Tracing/TracerProtocol.swift @@ -248,7 +248,8 @@ extension Tracer { function: String = #function, file fileID: String = #fileID, line: UInt = #line, - @_inheritActorContext @_implicitSelfCapture _ operation: (Self.Span) async throws -> T + isolation: isolated (any Actor)? = #isolation, + _ operation: (Self.Span) async throws -> T ) async rethrows -> T { let span = self.startSpan( operationName, @@ -301,7 +302,8 @@ extension Tracer { function: String = #function, file fileID: String = #fileID, line: UInt = #line, - @_inheritActorContext @_implicitSelfCapture _ operation: (Self.Span) async throws -> T + isolation: isolated (any Actor)? = #isolation, + _ operation: (Self.Span) async throws -> T ) async rethrows -> T { let span = self.startSpan( operationName,