Merge "Upload soong_build_metrics"

This commit is contained in:
Jason Wu 2022-12-12 16:22:16 +00:00 committed by Gerrit Code Review
commit 92c6c2b2ef
2 changed files with 8 additions and 5 deletions

View file

@ -117,6 +117,7 @@ func inList(s string, list []string) bool {
// Command is the type of soong_ui execution. Only one type of // Command is the type of soong_ui execution. Only one type of
// execution is specified. The args are specific to the command. // execution is specified. The args are specific to the command.
func main() { func main() {
//TODO(juu): Add logic to soong_ui to delete a hardcoded list of metrics files
shared.ReexecWithDelveMaybe(os.Getenv("SOONG_UI_DELVE"), shared.ResolveDelveBinary()) shared.ReexecWithDelveMaybe(os.Getenv("SOONG_UI_DELVE"), shared.ResolveDelveBinary())
buildStarted := time.Now() buildStarted := time.Now()
@ -184,6 +185,7 @@ func main() {
rbeMetricsFile := filepath.Join(logsDir, c.logsPrefix+"rbe_metrics.pb") rbeMetricsFile := filepath.Join(logsDir, c.logsPrefix+"rbe_metrics.pb")
soongMetricsFile := filepath.Join(logsDir, c.logsPrefix+"soong_metrics") soongMetricsFile := filepath.Join(logsDir, c.logsPrefix+"soong_metrics")
bp2buildMetricsFile := filepath.Join(logsDir, c.logsPrefix+"bp2build_metrics.pb") bp2buildMetricsFile := filepath.Join(logsDir, c.logsPrefix+"bp2build_metrics.pb")
soongBuildMetricsFile := filepath.Join(logsDir, c.logsPrefix+"soong_build_metrics.pb")
build.PrintOutDirWarning(buildCtx, config) build.PrintOutDirWarning(buildCtx, config)
@ -211,6 +213,7 @@ func main() {
files := []string{ files := []string{
buildErrorFile, // build error strings buildErrorFile, // build error strings
rbeMetricsFile, // high level metrics related to remote build execution. rbeMetricsFile, // high level metrics related to remote build execution.
soongBuildMetricsFile, // high level metrics related to soong build(except bp2build).
bp2buildMetricsFile, // high level metrics related to bp2build. bp2buildMetricsFile, // high level metrics related to bp2build.
soongMetricsFile, // high level metrics related to this build system. soongMetricsFile, // high level metrics related to this build system.
config.BazelMetricsDir(), // directory that contains a set of bazel metrics. config.BazelMetricsDir(), // directory that contains a set of bazel metrics.
@ -219,7 +222,6 @@ func main() {
if !config.SkipMetricsUpload() { if !config.SkipMetricsUpload() {
defer build.UploadMetrics(buildCtx, config, c.simpleOutput, buildStarted, files...) defer build.UploadMetrics(buildCtx, config, c.simpleOutput, buildStarted, files...)
} }
defer met.Dump(soongMetricsFile) defer met.Dump(soongMetricsFile)
defer build.CheckProdCreds(buildCtx, config) defer build.CheckProdCreds(buildCtx, config)
} }

View file

@ -566,11 +566,12 @@ func runSoong(ctx Context, config Config) {
targets = append(targets, config.SoongNinjaFile()) targets = append(targets, config.SoongNinjaFile())
} }
// TODO(juu): Stop embedding soong_build_metrics in soong_metrics.
soongBuildMetricsFile := filepath.Join(config.LogsDir(), "soong_build_metrics.pb")
if err := os.Remove(soongBuildMetricsFile); err != nil && !os.IsNotExist(err) {
ctx.Verbosef("Failed to remove %s", soongBuildMetricsFile)
}
if shouldCollectBuildSoongMetrics(config) { if shouldCollectBuildSoongMetrics(config) {
soongBuildMetricsFile := filepath.Join(config.LogsDir(), "soong_build_metrics.pb")
if err := os.Remove(soongBuildMetricsFile); err != nil && !os.IsNotExist(err) {
ctx.Verbosef("Failed to remove %s", soongBuildMetricsFile)
}
defer func() { defer func() {
soongBuildMetrics := loadSoongBuildMetrics(ctx, soongBuildMetricsFile) soongBuildMetrics := loadSoongBuildMetrics(ctx, soongBuildMetricsFile)
if soongBuildMetrics != nil { if soongBuildMetrics != nil {