@@ -315,12 +315,42 @@ public func withSpan<T>(
315
315
/// - instant: the time instant at which the span started
316
316
/// - context: The `ServiceContext` providing information on where to start the new ``Span``.
317
317
/// - kind: The ``SpanKind`` of the new ``Span``.
318
+ /// - isolation: Defaulted parameter for inheriting isolation of calling actor
318
319
/// - function: The function name in which the span was started
319
320
/// - fileID: The `fileID` where the span was started.
320
321
/// - line: The file line where the span was started.
321
322
/// - operation: The operation that this span should be measuring
322
323
/// - Returns: the value returned by `operation`
323
324
/// - Throws: the error the `operation` has thrown (if any)
325
+ #if swift(>=6.0)
326
+ @available ( macOS 10 . 15 , iOS 13 , tvOS 13 , watchOS 6 , * ) // for TaskLocal ServiceContext
327
+ public func withSpan< T, Instant: TracerInstant > (
328
+ _ operationName: String ,
329
+ at instant: @autoclosure ( ) -> Instant ,
330
+ context: @autoclosure ( ) -> ServiceContext = . current ?? . topLevel,
331
+ ofKind kind: SpanKind = . internal,
332
+ isolation: isolated( any Actor ) ? = #isolation,
333
+ function: String = #function,
334
+ file fileID: String = #fileID,
335
+ line: UInt = #line,
336
+ _ operation: ( any Span ) async throws -> T
337
+ ) async rethrows -> T {
338
+ try await InstrumentationSystem . legacyTracer. withAnySpan (
339
+ operationName,
340
+ at: instant ( ) ,
341
+ context: context ( ) ,
342
+ ofKind: kind,
343
+ function: function,
344
+ file: fileID,
345
+ line: line
346
+ ) { anySpan in
347
+ try await operation ( anySpan)
348
+ }
349
+ }
350
+ #endif
351
+
352
+ @_disfavoredOverload
353
+ @available ( * , deprecated, message: " Prefer #isolation version of this API " )
324
354
@available ( macOS 10 . 15 , iOS 13 , tvOS 13 , watchOS 6 , * ) // for TaskLocal ServiceContext
325
355
public func withSpan< T, Instant: TracerInstant > (
326
356
_ operationName: String ,
@@ -360,13 +390,42 @@ public func withSpan<T, Instant: TracerInstant>(
360
390
/// - Parameters:
361
391
/// - operationName: The name of the operation being traced. This may be a handler function, database call, ...
362
392
/// - context: The `ServiceContext` providing information on where to start the new ``Span``.
363
- /// - kind: The ``SpanKind`` of the new ``Span``.
393
+ /// - ofKind: The ``SpanKind`` of the new ``Span``.
394
+ /// - isolation: Defaulted parameter for inheriting isolation of calling actor
364
395
/// - function: The function name in which the span was started
365
396
/// - fileID: The `fileID` where the span was started.
366
397
/// - line: The file line where the span was started.
367
398
/// - operation: The operation that this span should be measuring
368
399
/// - Returns: the value returned by `operation`
369
400
/// - Throws: the error the `operation` has thrown (if any)
401
+ #if swift(>=6.0)
402
+ @available ( macOS 10 . 15 , iOS 13 , tvOS 13 , watchOS 6 , * ) // for TaskLocal ServiceContext
403
+ public func withSpan< T> (
404
+ _ operationName: String ,
405
+ context: @autoclosure ( ) -> ServiceContext = . current ?? . topLevel,
406
+ ofKind kind: SpanKind = . internal,
407
+ isolation: isolated( any Actor ) ? = #isolation,
408
+ function: String = #function,
409
+ file fileID: String = #fileID,
410
+ line: UInt = #line,
411
+ _ operation: ( any Span ) async throws -> T
412
+ ) async rethrows -> T {
413
+ try await InstrumentationSystem . legacyTracer. withAnySpan (
414
+ operationName,
415
+ at: DefaultTracerClock . now,
416
+ context: context ( ) ,
417
+ ofKind: kind,
418
+ function: function,
419
+ file: fileID,
420
+ line: line
421
+ ) { anySpan in
422
+ try await operation ( anySpan)
423
+ }
424
+ }
425
+ #endif
426
+
427
+ @_disfavoredOverload
428
+ @available ( * , deprecated, message: " Prefer #isolation version of this API " )
370
429
@available ( macOS 10 . 15 , iOS 13 , tvOS 13 , watchOS 6 , * ) // for TaskLocal ServiceContext
371
430
public func withSpan< T> (
372
431
_ operationName: String ,
@@ -407,12 +466,42 @@ public func withSpan<T>(
407
466
/// - context: The `ServiceContext` providing information on where to start the new ``Span``.
408
467
/// - kind: The ``SpanKind`` of the new ``Span``.
409
468
/// - instant: the time instant at which the span started
469
+ /// - isolation: Defaulted parameter for inheriting isolation of calling actor
410
470
/// - function: The function name in which the span was started
411
471
/// - fileID: The `fileID` where the span was started.
412
472
/// - line: The file line where the span was started.
413
473
/// - operation: The operation that this span should be measuring
414
474
/// - Returns: the value returned by `operation`
415
475
/// - Throws: the error the `operation` has thrown (if any)
476
+ #if swift(>=6.0)
477
+ @available ( macOS 10 . 15 , iOS 13 , tvOS 13 , watchOS 6 , * )
478
+ public func withSpan< T> (
479
+ _ operationName: String ,
480
+ context: @autoclosure ( ) -> ServiceContext = . current ?? . topLevel,
481
+ ofKind kind: SpanKind = . internal,
482
+ at instant: @autoclosure ( ) -> some TracerInstant = DefaultTracerClock . now,
483
+ isolation: isolated( any Actor ) ? = #isolation,
484
+ function: String = #function,
485
+ file fileID: String = #fileID,
486
+ line: UInt = #line,
487
+ _ operation: ( any Span ) async throws -> T
488
+ ) async rethrows -> T {
489
+ try await InstrumentationSystem . legacyTracer. withAnySpan (
490
+ operationName,
491
+ at: instant ( ) ,
492
+ context: context ( ) ,
493
+ ofKind: kind,
494
+ function: function,
495
+ file: fileID,
496
+ line: line
497
+ ) { anySpan in
498
+ try await operation ( anySpan)
499
+ }
500
+ }
501
+ #endif
502
+
503
+ @_disfavoredOverload
504
+ @available ( * , deprecated, message: " Prefer #isolation version of this API " )
416
505
@available ( macOS 10 . 15 , iOS 13 , tvOS 13 , watchOS 6 , * )
417
506
public func withSpan< T> (
418
507
_ operationName: String ,
0 commit comments