-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adopt Swift 6.0 #isolation; Resolves async closure behavior in withSpan #148
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -315,12 +315,42 @@ public func withSpan<T>( | |
/// - 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 | ||
/// - function: The function name in which the span was started | ||
/// - fileID: The `fileID` where the span was started. | ||
/// - line: The file line where the span was started. | ||
/// - 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 swift(>=6.0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is |
||
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext | ||
public func withSpan<T, Instant: TracerInstant>( | ||
_ operationName: String, | ||
at instant: @autoclosure () -> Instant, | ||
context: @autoclosure () -> ServiceContext = .current ?? .topLevel, | ||
ofKind kind: SpanKind = .internal, | ||
isolation: isolated(any Actor)? = #isolation, | ||
function: String = #function, | ||
file fileID: String = #fileID, | ||
line: UInt = #line, | ||
_ operation: (any Span) async throws -> T | ||
) async rethrows -> T { | ||
try await InstrumentationSystem.legacyTracer.withAnySpan( | ||
operationName, | ||
at: instant(), | ||
context: context(), | ||
ofKind: kind, | ||
function: function, | ||
file: fileID, | ||
line: line | ||
) { anySpan in | ||
try await operation(anySpan) | ||
} | ||
} | ||
#endif | ||
|
||
@_disfavoredOverload | ||
@available(*, deprecated, message: "Prefer #isolation version of this API") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the |
||
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext | ||
public func withSpan<T, Instant: TracerInstant>( | ||
_ operationName: String, | ||
|
@@ -360,13 +390,42 @@ public func withSpan<T, Instant: TracerInstant>( | |
/// - Parameters: | ||
/// - operationName: The name of the operation being traced. This may be a handler function, database call, ... | ||
/// - context: The `ServiceContext` providing information on where to start the new ``Span``. | ||
/// - kind: The ``SpanKind`` of the new ``Span``. | ||
/// - ofKind: The ``SpanKind`` of the new ``Span``. | ||
/// - isolation: Defaulted parameter for inheriting isolation of calling actor | ||
/// - function: The function name in which the span was started | ||
/// - fileID: The `fileID` where the span was started. | ||
/// - line: The file line where the span was started. | ||
/// - 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 swift(>=6.0) | ||
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext | ||
public func withSpan<T>( | ||
_ operationName: String, | ||
context: @autoclosure () -> ServiceContext = .current ?? .topLevel, | ||
ofKind kind: SpanKind = .internal, | ||
isolation: isolated(any Actor)? = #isolation, | ||
function: String = #function, | ||
file fileID: String = #fileID, | ||
line: UInt = #line, | ||
_ operation: (any Span) async throws -> T | ||
) async rethrows -> T { | ||
try await InstrumentationSystem.legacyTracer.withAnySpan( | ||
operationName, | ||
at: DefaultTracerClock.now, | ||
context: context(), | ||
ofKind: kind, | ||
function: function, | ||
file: fileID, | ||
line: line | ||
) { anySpan in | ||
try await operation(anySpan) | ||
} | ||
} | ||
#endif | ||
|
||
@_disfavoredOverload | ||
@available(*, deprecated, message: "Prefer #isolation version of this API") | ||
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext | ||
public func withSpan<T>( | ||
_ operationName: String, | ||
|
@@ -407,12 +466,42 @@ public func withSpan<T>( | |
/// - 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 was started | ||
/// - fileID: The `fileID` where the span was started. | ||
/// - line: The file line where the span was started. | ||
/// - 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 swift(>=6.0) | ||
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) | ||
public func withSpan<T>( | ||
_ operationName: String, | ||
context: @autoclosure () -> ServiceContext = .current ?? .topLevel, | ||
ofKind kind: SpanKind = .internal, | ||
at instant: @autoclosure () -> some TracerInstant = DefaultTracerClock.now, | ||
isolation: isolated(any Actor)? = #isolation, | ||
function: String = #function, | ||
file fileID: String = #fileID, | ||
line: UInt = #line, | ||
_ operation: (any Span) async throws -> T | ||
) async rethrows -> T { | ||
try await InstrumentationSystem.legacyTracer.withAnySpan( | ||
operationName, | ||
at: instant(), | ||
context: context(), | ||
ofKind: kind, | ||
function: function, | ||
file: fileID, | ||
line: line | ||
) { anySpan in | ||
try await operation(anySpan) | ||
} | ||
} | ||
#endif | ||
|
||
@_disfavoredOverload | ||
@available(*, deprecated, message: "Prefer #isolation version of this API") | ||
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) | ||
public func withSpan<T>( | ||
_ operationName: String, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doc comment is wrong, should be
ofKind
to match the public APIThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure? https://www.swift.org/documentation/docc/writing-symbol-documentation-in-your-source-files shows to document the actual second name, as those are unique and the prior labels aren't.