Refactor upload-only to process bazel metrics outside of upload.go

Bug: 279987768
Test: m nothing
Test: b build libcore:all (with prints to verify similiar data)
Change-Id: I01d960a7215be30728c9e90f52c2455fd21cf1b8
This commit is contained in:
MarkDacek
2023-05-09 18:21:36 +00:00
parent 3e63067b11
commit 733b77c2de
5 changed files with 150 additions and 119 deletions

View File

@@ -99,7 +99,7 @@ var commands = []command{
// Upload-only mode mostly skips to the metrics-uploading phase of soong_ui.
// However, this invocation marks the true "end of the build", and thus we
// need to update the total runtime of the build to include this upload step.
run: updateTotalRealTime,
run: finalizeBazelMetrics,
},
}
@@ -203,8 +203,6 @@ func main() {
bazelMetricsFile := filepath.Join(logsDir, c.logsPrefix+"bazel_metrics.pb")
soongBuildMetricsFile := filepath.Join(logsDir, c.logsPrefix+"soong_build_metrics.pb")
//the profile file generated by Bazel"
bazelProfileFile := filepath.Join(logsDir, c.logsPrefix+"analyzed_bazel_profile.txt")
metricsFiles := []string{
buildErrorFile, // build error strings
rbeMetricsFile, // high level metrics related to remote build execution.
@@ -226,7 +224,7 @@ func main() {
criticalPath.WriteToMetrics(met)
met.Dump(soongMetricsFile)
if !config.SkipMetricsUpload() {
build.UploadMetrics(buildCtx, config, c.simpleOutput, buildStarted, bazelProfileFile, bazelMetricsFile, metricsFiles...)
build.UploadMetrics(buildCtx, config, c.simpleOutput, buildStarted, metricsFiles...)
}
}()
c.run(buildCtx, config, args)
@@ -692,6 +690,15 @@ func setMaxFiles(ctx build.Context) {
}
}
func finalizeBazelMetrics(ctx build.Context, config build.Config, args []string) {
updateTotalRealTime(ctx, config, args)
logsDir := config.LogsDir()
logsPrefix := config.GetLogsPrefix()
bazelMetricsFile := filepath.Join(logsDir, logsPrefix+"bazel_metrics.pb")
bazelProfileFile := filepath.Join(logsDir, logsPrefix+"analyzed_bazel_profile.txt")
build.ProcessBazelMetrics(bazelProfileFile, bazelMetricsFile, ctx, config)
}
func updateTotalRealTime(ctx build.Context, config build.Config, args []string) {
soongMetricsFile := filepath.Join(config.LogsDir(), "soong_metrics")