Report hot reload statistics. (#26039)

* Report hot reload statistic

* Lints

* Introduce custom dimensions identifiers to track hot reload stats
This commit is contained in:
Alexander Aprelev
2019-01-05 07:34:02 -08:00
committed by GitHub
parent dbe001f50d
commit 6502a1bed9
2 changed files with 22 additions and 4 deletions

View File

@@ -592,10 +592,10 @@ class HotRunner extends ResidentRunner {
}
Future<OperationResult> _reloadSources({ bool pause = false, String reason }) async {
final Map<String, String> analyticsParameters =
reason == null
? null
: <String, String>{ kEventReloadReasonParameterName: reason };
final Map<String, String> analyticsParameters = <String, String> {};
if (reason != null) {
analyticsParameters[kEventReloadReasonParameterName] = reason;
}
for (FlutterDevice device in flutterDevices) {
for (FlutterView view in device.views) {
if (view.uiIsolate == null)
@@ -663,6 +663,18 @@ class HotRunner extends ResidentRunner {
flutterUsage.sendEvent('hot', 'reload-reject');
return OperationResult(1, 'Reload rejected');
} else {
// Collect stats that help understand scale of update for this hot reload request.
// For example, [syncedLibraryCount]/[finalLibraryCount] indicates how
// many libraries were affected by the hot reload request.
// Relation of [invalidatedSourcesCount] to [syncedLibraryCount] should help
// understand sync/transfer "overhead" of updating this number of source files.
final Map<String, dynamic> details = reloadReport['details'];
analyticsParameters[kEventReloadFinalLibraryCount] = "${details['finalLibraryCount']}";
analyticsParameters[kEventReloadSyncedLibraryCount] = "${details['receivedLibraryCount']}";
analyticsParameters[kEventReloadSyncedClassesCount] = "${details['receivedClassesCount']}";
analyticsParameters[kEventReloadSyncedProceduresCount] = "${details['receivedProceduresCount']}";
analyticsParameters[kEventReloadSyncedBytes] = '${updatedDevFS.syncedBytes}';
analyticsParameters[kEventReloadInvalidatedSourcesCount] = '${updatedDevFS.invalidatedSourcesCount}';
flutterUsage.sendEvent('hot', 'reload', parameters: analyticsParameters);
final int loadedLibraryCount = reloadReport['details']['loadedLibraryCount'];
final int finalLibraryCount = reloadReport['details']['finalLibraryCount'];

View File

@@ -17,6 +17,12 @@ import 'version.dart';
const String _kFlutterUA = 'UA-67589403-6';
const String kEventReloadReasonParameterName = 'cd5';
const String kEventReloadFinalLibraryCount = 'cd6';
const String kEventReloadSyncedLibraryCount = 'cd7';
const String kEventReloadSyncedClassesCount = 'cd8';
const String kEventReloadSyncedProceduresCount = 'cd9';
const String kEventReloadSyncedBytes = 'cd10';
const String kEventReloadInvalidatedSourcesCount = 'cd11';
Usage get flutterUsage => Usage.instance;