Add new fields - |upstream_events| and |duration_millis| in stats.proto
Revise annotations in previous fields and deprecate |upstream_type|.
Ignore-AOSP-First: Merge conflict if submits in AOSP first.
Bug: 153942334
Test: statsd_testdrive 303
Change-Id: Id4d594f9238e18266dce5bf2ba238c1f86f655db
(cherry picked from commit 71c8495cea8d8523286891d5b20b563be8382e52)
Merged-In: Id4d594f9238e18266dce5bf2ba238c1f86f655db
diff --git a/Tethering/src/com/android/networkstack/tethering/metrics/TetheringMetrics.java b/Tethering/src/com/android/networkstack/tethering/metrics/TetheringMetrics.java
index d8e631e..2c6054d 100644
--- a/Tethering/src/com/android/networkstack/tethering/metrics/TetheringMetrics.java
+++ b/Tethering/src/com/android/networkstack/tethering/metrics/TetheringMetrics.java
@@ -75,6 +75,8 @@
.setUserType(userTypeToEnum(callerPkg))
.setUpstreamType(UpstreamType.UT_UNKNOWN)
.setErrorCode(ErrorCode.EC_NO_ERROR)
+ .setUpstreamEvents(UpstreamEvents.newBuilder())
+ .setDurationMillis(0)
.build();
mBuilderMap.put(downstreamType, statsBuilder);
}
@@ -110,7 +112,8 @@
reported.getErrorCode().getNumber(),
reported.getDownstreamType().getNumber(),
reported.getUpstreamType().getNumber(),
- reported.getUserType().getNumber());
+ reported.getUserType().getNumber(),
+ null, 0);
if (DBG) {
Log.d(TAG, "Write errorCode: " + reported.getErrorCode().getNumber()
+ ", downstreamType: " + reported.getDownstreamType().getNumber()
diff --git a/Tethering/src/com/android/networkstack/tethering/metrics/stats.proto b/Tethering/src/com/android/networkstack/tethering/metrics/stats.proto
index 46a47af..27f2126 100644
--- a/Tethering/src/com/android/networkstack/tethering/metrics/stats.proto
+++ b/Tethering/src/com/android/networkstack/tethering/metrics/stats.proto
@@ -21,12 +21,38 @@
import "frameworks/proto_logging/stats/enums/stats/connectivity/tethering.proto";
+// Logs each upstream for a successful switch over
+message UpstreamEvent {
+ // Transport type of upstream network
+ optional .android.stats.connectivity.UpstreamType upstream_type = 1;
+
+ // A time period that an upstream continued
+ optional int64 duration_millis = 2;
+}
+
+message UpstreamEvents {
+ repeated UpstreamEvent upstream_event = 1;
+}
+
/**
* Logs Tethering events
*/
message NetworkTetheringReported {
- optional .android.stats.connectivity.ErrorCode error_code = 1;
- optional .android.stats.connectivity.DownstreamType downstream_type = 2;
- optional .android.stats.connectivity.UpstreamType upstream_type = 3;
- optional .android.stats.connectivity.UserType user_type = 4;
+ // Tethering error code
+ optional .android.stats.connectivity.ErrorCode error_code = 1;
+
+ // Tethering downstream type
+ optional .android.stats.connectivity.DownstreamType downstream_type = 2;
+
+ // Transport type of upstream network
+ optional .android.stats.connectivity.UpstreamType upstream_type = 3 [deprecated = true];
+
+ // The user type of switching tethering
+ optional .android.stats.connectivity.UserType user_type = 4;
+
+ // Log each transport type of upstream network event
+ optional UpstreamEvents upstream_events = 5;
+
+ // A time period that a downstreams exists
+ optional int64 duration_millis = 6;
}
diff --git a/Tethering/tests/unit/src/com/android/networkstack/tethering/metrics/TetheringMetricsTest.java b/Tethering/tests/unit/src/com/android/networkstack/tethering/metrics/TetheringMetricsTest.java
index 6a85718..7fdde97 100644
--- a/Tethering/tests/unit/src/com/android/networkstack/tethering/metrics/TetheringMetricsTest.java
+++ b/Tethering/tests/unit/src/com/android/networkstack/tethering/metrics/TetheringMetricsTest.java
@@ -88,6 +88,8 @@
.setUserType(user)
.setUpstreamType(UpstreamType.UT_UNKNOWN)
.setErrorCode(error)
+ .setUpstreamEvents(UpstreamEvents.newBuilder())
+ .setDurationMillis(0)
.build();
verify(mTetheringMetrics).write(expectedReport);
}