open-telemetry / opentelemetry-swift

OpenTelemetry API for Swift
https://opentelemetry.io/docs/instrumentation/swift/
Apache License 2.0
207 stars 124 forks source link

When using network instrumentation, network background tasks failes as the reported image. #552

Open lelinolino opened 1 month ago

lelinolino commented 1 month ago

This is my code where I initialize the instrumentation:

_ = URLSessionInstrumentation(configuration: URLSessionInstrumentationConfiguration( shouldInstrument: { request in
            if request.url?.absoluteString.contains( "something" ) ?? false {
                return false
            }
            return true
        }, nameSpan: { request in
            if request.url?.path().contains("something") ?? false{
                return "name"
            }
            return request.url?.path()
        }))
Screenshot 2024-07-08 alle 17 13 57
atreat commented 4 weeks ago

Looks like using the URLSessionConfiguration.identifier is the best way to determine if we're using a background configuration. We'll need to check this before setting the URLSessionDelegate

nachoBonafonte commented 1 day ago

Hi @lelinolino, could you test with the change in that PR and see if it fixes the crashes? The background network task won't be instrumented, but at least it should not crash