Migrate NetworkStack metrics off StatsLog.write
Now that the new metrics API can be used, NetworkStack
metrics need to migrate off the legacy StatsLog.write.
Bug: 130323000
Test: Test with ./out/host/linux-x86/bin/statsd_testdrive 121
to ensure log properly
Test: Ensure NetworkStackStatsLog will be generated as expected
Test: atest NetworkStackTest
Change-Id: I8c70503cf1d9f1d06f30a1936d2d88857d0cff53
This commit is contained in:
@@ -208,7 +208,7 @@ message Atom {
|
|||||||
119 [(log_from_module) = "docsui"];
|
119 [(log_from_module) = "docsui"];
|
||||||
DocsUISearchTypeReported docs_ui_search_type_reported =
|
DocsUISearchTypeReported docs_ui_search_type_reported =
|
||||||
120 [(log_from_module) = "docsui"];
|
120 [(log_from_module) = "docsui"];
|
||||||
DataStallEvent data_stall_event = 121;
|
DataStallEvent data_stall_event = 121 [(log_from_module) = "network_stack"];
|
||||||
RescuePartyResetReported rescue_party_reset_reported = 122;
|
RescuePartyResetReported rescue_party_reset_reported = 122;
|
||||||
SignedConfigReported signed_config_reported = 123;
|
SignedConfigReported signed_config_reported = 123;
|
||||||
GnssNiEventReported gnss_ni_event_reported = 124;
|
GnssNiEventReported gnss_ni_event_reported = 124;
|
||||||
@@ -269,7 +269,7 @@ message Atom {
|
|||||||
StyleUIChanged style_ui_changed = 179;
|
StyleUIChanged style_ui_changed = 179;
|
||||||
PrivacyIndicatorsInteracted privacy_indicators_interacted = 180;
|
PrivacyIndicatorsInteracted privacy_indicators_interacted = 180;
|
||||||
AppInstallOnExternalStorageReported app_install_on_external_storage_reported = 181;
|
AppInstallOnExternalStorageReported app_install_on_external_storage_reported = 181;
|
||||||
NetworkStackReported network_stack_reported = 182;
|
NetworkStackReported network_stack_reported = 182 [(log_from_module) = "network_stack"];
|
||||||
AppMovedStorageReported app_moved_storage_reported = 183;
|
AppMovedStorageReported app_moved_storage_reported = 183;
|
||||||
BiometricEnrolled biometric_enrolled = 184;
|
BiometricEnrolled biometric_enrolled = 184;
|
||||||
SystemServerWatchdogOccurred system_server_watchdog_occurred = 185;
|
SystemServerWatchdogOccurred system_server_watchdog_occurred = 185;
|
||||||
|
|||||||
@@ -198,11 +198,6 @@ public final class StatsLog extends StatsLogInternal {
|
|||||||
write(id, (long) params[0], (int) params[1], (String) params[2], (String) params[3],
|
write(id, (long) params[0], (int) params[1], (String) params[2], (String) params[3],
|
||||||
(boolean) params[4], (int) params[5]);
|
(boolean) params[4], (int) params[5]);
|
||||||
break;
|
break;
|
||||||
case DATA_STALL_EVENT:
|
|
||||||
// Refer to the defintion in frameworks/base/cmds/statsd/src/atoms.proto.
|
|
||||||
write(id, (int) params[0], (int) params[1], (int) params[2], (byte[]) params[3],
|
|
||||||
(byte[]) params[4], (byte[]) params[5]);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ android_library {
|
|||||||
"src/**/*.java",
|
"src/**/*.java",
|
||||||
":framework-networkstack-shared-srcs",
|
":framework-networkstack-shared-srcs",
|
||||||
":services-networkstack-shared-srcs",
|
":services-networkstack-shared-srcs",
|
||||||
|
":statslog-networkstack-java-gen",
|
||||||
],
|
],
|
||||||
static_libs: [
|
static_libs: [
|
||||||
"androidx.annotation_annotation",
|
"androidx.annotation_annotation",
|
||||||
@@ -104,3 +105,11 @@ android_app {
|
|||||||
certificate: "networkstack",
|
certificate: "networkstack",
|
||||||
manifest: "AndroidManifest.xml",
|
manifest: "AndroidManifest.xml",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
genrule {
|
||||||
|
name: "statslog-networkstack-java-gen",
|
||||||
|
tools: ["stats-log-api-gen"],
|
||||||
|
cmd: "$(location stats-log-api-gen) --java $(out) --module network_stack" +
|
||||||
|
" --javaPackage com.android.networkstack.metrics --javaClass NetworkStackStatsLog",
|
||||||
|
out: ["com/android/networkstack/metrics/NetworkStackStatsLog.java"],
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.metrics;
|
package com.android.networkstack.metrics;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
@@ -14,13 +14,12 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.metrics;
|
package com.android.networkstack.metrics;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.net.captiveportal.CaptivePortalProbeResult;
|
import android.net.captiveportal.CaptivePortalProbeResult;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.StatsLog;
|
|
||||||
|
|
||||||
import com.android.internal.util.HexDump;
|
import com.android.internal.util.HexDump;
|
||||||
import com.android.server.connectivity.nano.DataStallEventProto;
|
import com.android.server.connectivity.nano.DataStallEventProto;
|
||||||
@@ -37,13 +36,11 @@ import com.android.server.connectivity.nano.DataStallEventProto;
|
|||||||
*/
|
*/
|
||||||
public class DataStallStatsUtils {
|
public class DataStallStatsUtils {
|
||||||
private static final String TAG = DataStallStatsUtils.class.getSimpleName();
|
private static final String TAG = DataStallStatsUtils.class.getSimpleName();
|
||||||
private static final int DATA_STALL_EVENT_ID = 121;
|
|
||||||
private static final boolean DBG = false;
|
private static final boolean DBG = false;
|
||||||
|
|
||||||
private static int probeResultToEnum(@Nullable final CaptivePortalProbeResult result) {
|
private static int probeResultToEnum(@Nullable final CaptivePortalProbeResult result) {
|
||||||
if (result == null) return DataStallEventProto.INVALID;
|
if (result == null) return DataStallEventProto.INVALID;
|
||||||
|
|
||||||
// TODO: Add partial connectivity support.
|
|
||||||
if (result.isSuccessful()) {
|
if (result.isSuccessful()) {
|
||||||
return DataStallEventProto.VALID;
|
return DataStallEventProto.VALID;
|
||||||
} else if (result.isPortal()) {
|
} else if (result.isPortal()) {
|
||||||
@@ -65,8 +62,7 @@ public class DataStallStatsUtils {
|
|||||||
Log.d(TAG, "write: " + stats + " with result: " + validationResult
|
Log.d(TAG, "write: " + stats + " with result: " + validationResult
|
||||||
+ ", dns: " + HexDump.toHexString(stats.mDns));
|
+ ", dns: " + HexDump.toHexString(stats.mDns));
|
||||||
}
|
}
|
||||||
// TODO(b/124613085): Update API once the public StatsLog API is ready.
|
NetworkStackStatsLog.write(NetworkStackStatsLog.DATA_STALL_EVENT,
|
||||||
StatsLog.write(DATA_STALL_EVENT_ID,
|
|
||||||
stats.mEvaluationType,
|
stats.mEvaluationType,
|
||||||
validationResult,
|
validationResult,
|
||||||
stats.mNetworkType,
|
stats.mNetworkType,
|
||||||
@@ -65,8 +65,6 @@ import android.net.TrafficStats;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.net.captiveportal.CaptivePortalProbeResult;
|
import android.net.captiveportal.CaptivePortalProbeResult;
|
||||||
import android.net.captiveportal.CaptivePortalProbeSpec;
|
import android.net.captiveportal.CaptivePortalProbeSpec;
|
||||||
import android.net.metrics.DataStallDetectionStats;
|
|
||||||
import android.net.metrics.DataStallStatsUtils;
|
|
||||||
import android.net.metrics.IpConnectivityLog;
|
import android.net.metrics.IpConnectivityLog;
|
||||||
import android.net.metrics.NetworkEvent;
|
import android.net.metrics.NetworkEvent;
|
||||||
import android.net.metrics.ValidationProbeEvent;
|
import android.net.metrics.ValidationProbeEvent;
|
||||||
@@ -101,6 +99,8 @@ import com.android.internal.util.RingBufferIndices;
|
|||||||
import com.android.internal.util.State;
|
import com.android.internal.util.State;
|
||||||
import com.android.internal.util.StateMachine;
|
import com.android.internal.util.StateMachine;
|
||||||
import com.android.networkstack.R;
|
import com.android.networkstack.R;
|
||||||
|
import com.android.networkstack.metrics.DataStallDetectionStats;
|
||||||
|
import com.android.networkstack.metrics.DataStallStatsUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
|
|||||||
@@ -59,8 +59,6 @@ import android.net.Network;
|
|||||||
import android.net.NetworkCapabilities;
|
import android.net.NetworkCapabilities;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.captiveportal.CaptivePortalProbeResult;
|
import android.net.captiveportal.CaptivePortalProbeResult;
|
||||||
import android.net.metrics.DataStallDetectionStats;
|
|
||||||
import android.net.metrics.DataStallStatsUtils;
|
|
||||||
import android.net.metrics.IpConnectivityLog;
|
import android.net.metrics.IpConnectivityLog;
|
||||||
import android.net.util.SharedLog;
|
import android.net.util.SharedLog;
|
||||||
import android.net.wifi.WifiInfo;
|
import android.net.wifi.WifiInfo;
|
||||||
@@ -78,6 +76,9 @@ import android.util.ArrayMap;
|
|||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
import com.android.networkstack.metrics.DataStallDetectionStats;
|
||||||
|
import com.android.networkstack.metrics.DataStallStatsUtils;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|||||||
Reference in New Issue
Block a user