diff --git a/docs/network-plugin.md b/docs/network-plugin.md index 48004b52a..196786365 100644 --- a/docs/network-plugin.md +++ b/docs/network-plugin.md @@ -16,9 +16,24 @@ To use the network plugin, you need to add the plugin to your Sonar client insta ```java import com.facebook.sonar.plugins.network.NetworkSonarPlugin; -client.addPlugin(new NetworkSonarPlugin()); +NetworkSonarPlugin networkSonarPlugin = new NetworkSonarPlugin(); +client.addPlugin(networkSonarPlugin); ``` +#### OkHttp Integration + +If you are using the popular OkHttp library, you can use the Interceptors system to automatically hook into your existing stack. + +```java +import com.facebook.sonar.plugins.network.SonarOkhttpInterceptor; + +new OkHttpClient.Builder() + .addNetworkInterceptor(new SonarOkhttpInterceptor(networkSonarPlugin)) + .build(); +``` + +As interceptors can modify the request and response, add the Sonar interceptor after all others to get an accurate view of the network traffic. + ### iOS ```objective-c