@@ -30,7 +30,7 @@ public class URLSessionInstrumentation {
30
30
private let queue = DispatchQueue ( label: " io.opentelemetry.ddnetworkinstrumentation " )
31
31
32
32
static var instrumentedKey = " io.opentelemetry.instrumentedCall "
33
-
33
+
34
34
static let avAssetDownloadTask : AnyClass ? = NSClassFromString ( " __NSCFBackgroundAVAssetDownloadTask " )
35
35
36
36
public private( set) var tracer : Tracer
@@ -107,7 +107,7 @@ public class URLSessionInstrumentation {
107
107
injectTaskDidCompleteWithErrorIntoDelegateClass ( cls: cls)
108
108
injectRespondsToSelectorIntoDelegateClass ( cls: cls)
109
109
// For future use
110
- if InstrumentationUtils . usesUndocumentedAsyncAwaitMethods {
110
+ if #available ( OSX 13 . 0 , iOS 16 . 0 , watchOS 9 . 0 , tvOS 16 . 0 , * ) {
111
111
injectTaskDidFinishCollectingMetricsIntoDelegateClass ( cls: cls)
112
112
}
113
113
@@ -552,7 +552,7 @@ public class URLSessionInstrumentation {
552
552
guard let taskId = objc_getAssociatedObject ( dataTask, & idKey) as? String else {
553
553
return
554
554
}
555
- self . setIdKey ( value: taskId, for: downloadTask)
555
+ setIdKey ( value: taskId, for: downloadTask)
556
556
}
557
557
558
558
private func urlSession( _ session: URLSession , task: URLSessionTask , didFinishCollecting metrics: URLSessionTaskMetrics ) {
@@ -587,7 +587,7 @@ public class URLSessionInstrumentation {
587
587
task. isKind ( of: avAssetTaskClass) {
588
588
return
589
589
}
590
-
590
+
591
591
let taskId = idKeyForTask ( task)
592
592
if let request = task. currentRequest {
593
593
queue. sync {
@@ -597,19 +597,17 @@ public class URLSessionInstrumentation {
597
597
requestMap [ taskId] ? . setRequest ( request)
598
598
}
599
599
600
- if InstrumentationUtils . usesUndocumentedAsyncAwaitMethods {
601
- if #available( OSX 13 . 0 , iOS 16 . 0 , watchOS 9 . 0 , tvOS 16 . 0 , * ) {
602
- guard Task . basePriority != nil else {
603
- return
604
- }
605
- let instrumentedRequest = URLSessionLogger . processAndLogRequest ( request, sessionTaskId: taskId, instrumentation: self , shouldInjectHeaders: true )
606
- task. setValue ( instrumentedRequest, forKey: " currentRequest " )
607
- self . setIdKey ( value: taskId, for: task)
600
+ if #available( OSX 13 . 0 , iOS 16 . 0 , watchOS 9 . 0 , tvOS 16 . 0 , * ) {
601
+ guard Task . basePriority != nil else {
602
+ return
603
+ }
604
+ let instrumentedRequest = URLSessionLogger . processAndLogRequest ( request, sessionTaskId: taskId, instrumentation: self , shouldInjectHeaders: true )
605
+ task. setValue ( instrumentedRequest, forKey: " currentRequest " )
606
+ self . setIdKey ( value: taskId, for: task)
608
607
609
- // If not inside a Task basePriority is nil
610
- if task. delegate == nil {
611
- task. delegate = FakeDelegate ( )
612
- }
608
+ // If not inside a Task basePriority is nil
609
+ if task. delegate == nil {
610
+ task. delegate = FakeDelegate ( )
613
611
}
614
612
}
615
613
}
0 commit comments