Search code examples
iosobjective-cswiftfirebasefirebase-performance

How Firebase Performance Monitoring intercepts outgoing http requests in iOS?


From firebase's help doc, it states

For all app types, Performance Monitoring automatically collects a trace for each network request issued by your app, called an HTTP/S network request trace Performance Monitoring automatically collects metrics for network requests that use the following networking libraries: URLSession, URLConnection

How are they tracking the http requests automatically ?


Solution

  • On iOS, Firebase Performance Monitoring uses method swizzling to effectively rewrite calls to NSURLConnection to its own implementation (which in turn calls back into the original iOS implementation). This allows the SDK to record what the app is doing for HTTP requests.