Skip to content

Commit

Permalink
tidied syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
bryce-b committed Nov 21, 2024
1 parent df96519 commit b799e43
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions Sources/Instrumentation/URLSession/URLSessionInstrumentation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,10 @@ public class URLSessionInstrumentation {
static var instrumentedKey = "io.opentelemetry.instrumentedCall"

static let AVTaskClassList : [AnyClass] = {
let names = ["__NSCFBackgroundAVAggregateAssetDownloadTask", "__NSCFBackgroundAVAssetDownloadTask", "__NSCFBackgroundAVAggregateAssetDownloadTaskNoChildTask" ]
var classes : [AnyClass] = []
for name in names {
if let aClass = NSClassFromString(name) {
classes.append(aClass)
}
}
return classes
["__NSCFBackgroundAVAggregateAssetDownloadTask",
"__NSCFBackgroundAVAssetDownloadTask",
"__NSCFBackgroundAVAggregateAssetDownloadTaskNoChildTask" ]
.compactMap { NSClassFromString($0) }
}()

public private(set) var tracer: Tracer
Expand Down Expand Up @@ -601,11 +597,7 @@ public class URLSessionInstrumentation {

private func urlSessionTaskWillResume(_ task: URLSessionTask) {
// AV Asset Tasks cannot be auto instrumented, they dont include request attributes, skip them
for aClass in Self.AVTaskClassList {
if task.isKind(of: aClass) {
return
}
}
guard !Self.AVTaskClassList.contains(where: {task.isKind(of:$0)}) else { return }

// We cannot instrument async background tasks because they crash if you assign a delegate
if #available(OSX 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) {
Expand Down

0 comments on commit b799e43

Please sign in to comment.