@@ -16,10 +16,10 @@ private let OS_ACTIVITY_CURRENT = unsafeBitCast(dlsym(UnsafeMutableRawPointer(bi
1616
1717class ActivityContextManager: ContextManager {
1818 static let instance = ActivityContextManager ( )
19- #if swift(>=5.5 )
19+ #if canImport(_Concurrency )
2020 @available ( macOS 12 . 0 , iOS 15 . 0 , tvOS 15 . 0 , * )
2121 static let taskLocalContextManager = TaskLocalContextManager . instance
22- #endif
22+ #endif
2323
2424 let rlock = NSRecursiveLock ( )
2525
@@ -38,14 +38,14 @@ class ActivityContextManager: ContextManager {
3838 var contextMap = [ os_activity_id_t: [ String: AnyObject] ] ( )
3939
4040 func getCurrentContextValue( forKey key: OpenTelemetryContextKeys ) -> AnyObject ? {
41- #if swift(>=5.5 )
41+ #if canImport(_Concurrency )
4242 if #available( macOS 12 . 0 , iOS 15 . 0 , tvOS 15 . 0 , * ) {
4343 // If running with task local, use first its stored value
4444 if let contextValue = ActivityContextManager . taskLocalContextManager. getCurrentContextValue ( forKey: key) {
4545 return contextValue
4646 }
4747 }
48- #endif
48+ #endif
4949 var parentIdent : os_activity_id_t = 0
5050 let activityIdent = os_activity_get_identifier ( OS_ACTIVITY_CURRENT, & parentIdent)
5151 var contextValue : AnyObject ?
@@ -70,12 +70,12 @@ class ActivityContextManager: ContextManager {
7070 objectScope. setObject ( ScopeElement ( scope: scope) , forKey: value)
7171 }
7272 contextMap [ activityIdent] ? [ key. rawValue] = value
73- #if swift(>=5.5 )
73+ #if canImport(_Concurrency )
7474 if #available( macOS 12 . 0 , iOS 15 . 0 , tvOS 15 . 0 , * ) {
7575 // If running with task local, set the value after the activity, so activity is not empty
7676 ActivityContextManager . taskLocalContextManager. setCurrentContextValue ( forKey: key, value: value)
7777 }
78- #endif
78+ #endif
7979 rlock. unlock ( )
8080 }
8181
@@ -94,14 +94,14 @@ class ActivityContextManager: ContextManager {
9494 os_activity_scope_leave ( & scope)
9595 objectScope. removeObject ( forKey: value)
9696 }
97- #if swift(>=5.5 )
97+ #if canImport(_Concurrency )
9898 if #available( macOS 12 . 0 , iOS 15 . 0 , tvOS 15 . 0 , * ) {
9999 // If there is a parent activity, set its content as the task local
100100 ActivityContextManager . taskLocalContextManager. removeContextValue ( forKey: key, value: value)
101101 if let currentContext = self . getCurrentContextValue ( forKey: key) {
102102 ActivityContextManager . taskLocalContextManager. setCurrentContextValue ( forKey: key, value: currentContext)
103103 }
104104 }
105- #endif
105+ #endif
106106 }
107107}
0 commit comments