@@ -16,10 +16,6 @@ private let OS_ACTIVITY_CURRENT = unsafeBitCast(dlsym(UnsafeMutableRawPointer(bi
1616
1717class ActivityContextManager: ContextManager {
1818 static let instance = ActivityContextManager ( )
19- #if swift(>=5.5.2)
20- @available ( macOS 10 . 15 , iOS 13 . 0 , tvOS 13 . 0 , * )
21- static let taskLocalContextManager = TaskLocalContextManager . instance
22- #endif
2319
2420 let rlock = NSRecursiveLock ( )
2521
@@ -28,8 +24,6 @@ class ActivityContextManager: ContextManager {
2824 self . scope = scope
2925 }
3026
31- deinit { }
32-
3327 var scope : os_activity_scope_state_s
3428 }
3529
@@ -38,13 +32,6 @@ class ActivityContextManager: ContextManager {
3832 var contextMap = [ os_activity_id_t: [ String: AnyObject] ] ( )
3933
4034 func getCurrentContextValue( forKey key: OpenTelemetryContextKeys ) -> AnyObject ? {
41- #if swift(>=5.5.2)
42- if #available( macOS 10 . 15 , iOS 13 . 0 , tvOS 13 . 0 , * ) {
43- if let contextValue = ActivityContextManager . taskLocalContextManager. getCurrentContextValue ( forKey: key) {
44- return contextValue
45- }
46- }
47- #endif
4835 var parentIdent : os_activity_id_t = 0
4936 let activityIdent = os_activity_get_identifier ( OS_ACTIVITY_CURRENT, & parentIdent)
5037 var contextValue : AnyObject ?
@@ -59,20 +46,6 @@ class ActivityContextManager: ContextManager {
5946 }
6047
6148 func setCurrentContextValue( forKey key: OpenTelemetryContextKeys , value: AnyObject ) {
62- #if swift(>=5.5.2)
63- if #available( macOS 10 . 15 , iOS 13 . 0 , tvOS 13 . 0 , * ) {
64- var insideTask = false
65- withUnsafeCurrentTask { task in
66- if task != nil {
67- insideTask = true
68- }
69- }
70- if insideTask {
71- ActivityContextManager . taskLocalContextManager. setCurrentContextValue ( forKey: key, value: value)
72- return
73- }
74- }
75- #endif
7649 var parentIdent : os_activity_id_t = 0
7750 var activityIdent = os_activity_get_identifier ( OS_ACTIVITY_CURRENT, & parentIdent)
7851 rlock. lock ( )
@@ -96,20 +69,6 @@ class ActivityContextManager: ContextManager {
9669 }
9770
9871 func removeContextValue( forKey key: OpenTelemetryContextKeys , value: AnyObject ) {
99- #if swift(>=5.5.2)
100- if #available( macOS 10 . 15 , iOS 13 . 0 , tvOS 13 . 0 , * ) {
101- var insideTask = false
102- withUnsafeCurrentTask { task in
103- if task != nil {
104- insideTask = true
105- }
106- }
107- if insideTask {
108- ActivityContextManager . taskLocalContextManager. removeContextValue ( forKey: key, value: value)
109- return
110- }
111- }
112- #endif
11372 if let scope = objectScope. object ( forKey: value) {
11473 var scope = scope. scope
11574 os_activity_scope_leave ( & scope)
0 commit comments