Use task name when uploading metrics to skia perf (#89004)

This commit is contained in:
keyonghan
2021-08-26 22:31:02 -07:00
committed by GitHub
parent 7df68b906c
commit db4c104c8e
5 changed files with 99 additions and 13 deletions

View File

@@ -21,6 +21,7 @@ class UploadResultsCommand extends Command<void> {
'checkouts run in detached HEAD state, so the branch must be passed.',
);
argParser.addOption('luci-builder', help: '[Flutter infrastructure] Name of the LUCI builder being run on.');
argParser.addOption('task-name', help: '[Flutter infrastructure] Name of the task being run on.');
argParser.addOption('test-status', help: 'Test status: Succeeded|Failed');
argParser.addOption('commit-time', help: 'Commit time in UNIX timestamp');
}
@@ -40,6 +41,7 @@ class UploadResultsCommand extends Command<void> {
final String? builderName = argResults!['luci-builder'] as String?;
final String? testStatus = argResults!['test-status'] as String?;
final String? commitTime = argResults!['commit-time'] as String?;
final String? taskName = argResults!['task-name'] as String?;
// Upload metrics to metrics_center from test runner when `commitTime` is specified. This
// is mainly for testing purpose.
@@ -47,7 +49,7 @@ class UploadResultsCommand extends Command<void> {
// TODO(keyong): remove try block to block test when this is validated to work https://github.com/flutter/flutter/issues/88484
try {
if (commitTime != null) {
await uploadToMetricsCenter(resultsPath, commitTime);
await uploadToMetricsCenter(resultsPath, commitTime, taskName);
print('Successfully uploaded metrics to metrics center');
}
} on Exception catch (e, stacktrace) {

View File

@@ -70,8 +70,33 @@ List<MetricPoint> parse(Map<String, dynamic> resultsJson) {
return metricPoints;
}
/// Upload metrics to GCS bucket used by Skia Perf.
///
/// Skia Perf picks up all available files under the folder, and
/// is robust to duplicate entries.
///
/// Files will be named based on `taskName`, such as
/// `complex_layout_scroll_perf__timeline_summary_values.json`.
/// If no `taskName` is specified, data will be saved to
/// `default_values.json`.
Future<void> upload(
FlutterDestination metricsDestination,
List<MetricPoint> metricPoints,
int commitTimeSinceEpoch,
String? taskName,
) async {
await metricsDestination.update(
metricPoints,
DateTime.fromMillisecondsSinceEpoch(
commitTimeSinceEpoch,
isUtc: true,
),
taskName ?? 'default',
);
}
/// Upload test metrics to metrics center.
Future<void> uploadToMetricsCenter(String? resultsPath, String? commitTime) async {
Future<void> uploadToMetricsCenter(String? resultsPath, String? commitTime, String? taskName) async {
int commitTimeSinceEpoch;
if (resultsPath == null) {
return;
@@ -86,11 +111,5 @@ Future<void> uploadToMetricsCenter(String? resultsPath, String? commitTime) asyn
resultsJson = json.decode(await resultFile.readAsString()) as Map<String, dynamic>;
final List<MetricPoint> metricPoints = parse(resultsJson);
final FlutterDestination metricsDestination = await connectFlutterDestination();
await metricsDestination.update(
metricPoints,
DateTime.fromMillisecondsSinceEpoch(
commitTimeSinceEpoch,
isUtc: true,
),
);
await upload(metricsDestination, metricPoints, commitTimeSinceEpoch, taskName);
}