Upload build.trace.gz for user builds.

Bug: 340206057
Test: Manually verified build.trace.gz was uploaded to build server.
Change-Id: I9c071188343baf7c11c30a5c4c1d1ca7bcaac06b
This commit is contained in:
Yu Liu 2024-05-16 23:15:49 +00:00
parent aac481527e
commit f2615e923e

View file

@ -155,7 +155,6 @@ func main() {
// Create a new trace file writer, making it log events to the log instance.
trace := tracer.New(log)
defer trace.Close()
// Create a new Status instance, which manages action counts and event output channels.
stat := &status.Status{}
@ -194,14 +193,29 @@ func main() {
soongMetricsFile := filepath.Join(logsDir, c.logsPrefix+"soong_metrics")
rbeMetricsFile := filepath.Join(logsDir, c.logsPrefix+"rbe_metrics.pb")
soongBuildMetricsFile := filepath.Join(logsDir, c.logsPrefix+"soong_build_metrics.pb")
buildTraceFile := filepath.Join(logsDir, c.logsPrefix+"build.trace.gz")
metricsFiles := []string{
buildErrorFile, // build error strings
rbeMetricsFile, // high level metrics related to remote build execution.
soongMetricsFile, // high level metrics related to this build system.
soongBuildMetricsFile, // high level metrics related to soong build
buildTraceFile,
}
defer func() {
stat.Finish()
criticalPath.WriteToMetrics(met)
met.Dump(soongMetricsFile)
if !config.SkipMetricsUpload() {
build.UploadMetrics(buildCtx, config, c.simpleOutput, buildStarted, metricsFiles...)
}
}()
// This has to come after the metrics uploading function, so that
// build.trace.gz is closed and ready for upload.
defer trace.Close()
os.MkdirAll(logsDir, 0777)
log.SetOutput(filepath.Join(logsDir, c.logsPrefix+"soong.log"))
@ -222,16 +236,7 @@ func main() {
config = freshConfig()
}
defer func() {
stat.Finish()
criticalPath.WriteToMetrics(met)
met.Dump(soongMetricsFile)
if !config.SkipMetricsUpload() {
build.UploadMetrics(buildCtx, config, c.simpleOutput, buildStarted, metricsFiles...)
}
}()
c.run(buildCtx, config, args)
}
// This function must not modify config, since product config may cause us to recreate the config,