Firebase 性能监控如何拦截 android 中的传出 http 请求?

How Firebase Performance Monitoring intercepts outgoing http requests in android?

firebase 的帮助文档 https://firebase.google.com/docs/perf-mon/network-traces?platform=android 中指出

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: OkHttp3, Java's URLConnection, Apache HttpClient

他们如何在不使用任何拦截器的情况下自动跟踪 http 请求?他们是否使用任何字节码操作来跟踪他们?

是的,它正在 Android 上使用字节码操作。这就是插件在构建时所做的。它会找到所有看起来像 HTTP 请求(URLConnection、Apache HTTPClient 和 OKHTTP)的 API 调用,并用一个对象装饰这些调用,该对象在运行时监视它们的使用。

如果您想深入了解其实际工作原理,watch this talk