Unverified Commit 6502a1be authored by Alexander Aprelev's avatar Alexander Aprelev Committed by GitHub

Report hot reload statistics. (#26039)

* Report hot reload statistic

* Lints

* Introduce custom dimensions identifiers to track hot reload stats
parent dbe001f5
......@@ -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'];
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment