Skip to content

0x03b Network_en

hui.zhao edited this page Mar 24, 2020 · 4 revisions

Network

Extra dependencies

If you use OkHttp to send network requests, you can add dependency to the project as following:

implementation 'cn.hikyson.godeye:godeye-okhttp:VERSION_NAME'

Install

Use the following configuration to install

GodEye.instance().install(GodEyeConfig.defaultConfigBuilder().withNetworkConfig(new GodEyeConfig.NetworkConfig()).build());

or

<network />

Network module need to install after AndroidGodEye Version 3.0

Production and consumption of data

The 'android-godeye-okhttp' module provides an utility for okhttp. Just set the interceptor and event monitoring for OkHttpClient:

OkNetworkCollectorFactory okNetworkCollectorFactory = new OkNetworkCollectorFactory();
OkHttpClient zygote = new OkHttpClient.Builder().eventListenerFactory(okNetworkCollectorFactory.addNetworkInterceptor(okNetworkCollectorFactory).build();

If you send network request by other client, you need to call GodEyeHelper.onNetworkEnd(NetworkInfo networkInfo) to produce network data

Use the following methods to observe the output:

try {
                GodEye.instance().observeModule(GodEye.ModuleName.NETWORK, new Consumer<NetworkInfo<HttpContent>>() {
                    @Override
                    public void accept(NetworkInfo<HttpContent> networkContentNetworkInfo) throws Exception {
                    }
                });
            } catch (UninstallException e) {
                e.printStackTrace();
            }

Callback after the end of each network request. networkContentNetworkInfo records the results of the network, include result code, message, time-consuming of each stage, payload, etc

DebugMonitor Dashboard

Debug Monitor Dashboard provides informations of whether the network is successful, result message, time-consuming and some other informations (such as connected IP, etc.)

android_god_eye_network

Clone this wiki locally