Performance analysis APIs

更新时间:
复制 MD 格式

Log APIs

By default, network performance analysis does not generate logs. Use the following APIs to enable logging.

Note

The log tag for network performance monitoring is: EmasNetwork

addLogger

Adds a logger.

Warning

This API was deprecated in Mobile Monitoring SDK v2.8.0.

Interface definition

void addLogger(Logger logger)

Class

NetworkMonitorManager

Parameters

Parameter

Type

Required

Description

logger

Logger

Yes

Sample code

import com.alibaba.sdk.android.networkmonitor.NetworkMonitorManager
import com.alibaba.sdk.android.networkmonitor.utils.Logger

NetworkMonitorManager.getInstance().addLogger(object : Logger {
    public override fun logd(tag: String?, msg: String?) {
        Log.d(tag, msg)
    }

    public override fun logi(tag: String?, msg: String?) {
        Log.i(tag, msg)
    }

    public override fun logw(tag: String?, msg: String?) {
        Log.w(tag, msg)
    }
})
import com.alibaba.sdk.android.networkmonitor.NetworkMonitorManager;
import com.alibaba.sdk.android.networkmonitor.utils.Logger;

NetworkMonitorManager.getInstance().addLogger(new Logger() {
    @Override
    public void logd(String tag, String msg) {
        Log.d(tag, msg);
    }

    @Override
    public void logi(String tag, String msg) {
        Log.i(tag, msg);
    }

    @Override
    public void logw(String tag, String msg) {
        Log.w(tag, msg);
    }
});

removeLogger

Removes a logger.

Warning

This API was deprecated in Mobile Monitoring SDK v2.8.0.

Interface definition

void removeLogger(Logger logger)

Class

NetworkMonitorManager

Parameters

Parameter

Type

Required

Description

logger

Logger

Yes

Launch analysis

startSpan

Starts a custom phase for launch analysis.

Interface definition

static void startSpan(@NonNull String name)

Class

LaunchAnalysis

Parameters

Parameter

Type

Required

Description

name

String

Yes

The name must not exceed 64 characters. The system discards spans with longer names.

endSpan

Ends a custom phase for launch analysis.

Interface definition

static void endSpan(@NonNull String name)

Class

LaunchAnalysis

Parameters

Parameter

Type

Required

Description

name

String

Yes

The name must not exceed 64 characters. The system discards spans with longer names.

reportLaunchEnd

Ends the app launch and reports the data.

Note

This method requires the customLaunchEnd option to be enabled.

Interface definition

static void reportLaunchEnd()

Class

LaunchAnalysis

Page analysis

startSpan

Starts a custom phase for page analysis.

Interface definition

static void startSpan(@NonNull Activity activity, @NonNull String name)

Class

PageAnalysis

Parameters

Parameter

Type

Required

Description

activity

Activity

Yes

name

String

Yes

The name must not exceed 64 characters. The system discards spans with longer names.

endSpan

Ends a custom phase for page analysis.

Interface definition

static void endSpan(@NonNull Activity activity, @NonNull String name)

Class

PageAnalysis

Parameters

Parameter

Type

Required

Description

activity

Activity

Yes

name

String

Yes

The name must not exceed 64 characters. The system discards spans with longer names.

Configuration

customLaunchEnd

Enables a custom launch end.

Note

By default, launch analysis ends when the first frame of the first page is rendered. To define a custom endpoint, enable this option and then call reportLaunchEnd to mark the end of the launch.

Interface definition

PerformanceOptions.Builder customLaunchEnd(boolean custom)

Class

PerformanceOptions.Builder

Parameters

Parameter

Type

Required

Description

custom

boolean

Yes

  • true: Enables custom launch end.

  • false: Disables custom launch end.

  • Default value: false.