Remove Bazel metrics/finalize-bazel-metrics.
Test: m nothing Change-Id: Idd4610aca77f0a5deeadc3b895869879ded6c16e
This commit is contained in:
parent
8f535b4189
commit
39825ead17
3 changed files with 1 additions and 77 deletions
|
@ -91,14 +91,6 @@ var commands = []command{
|
|||
config: buildActionConfig,
|
||||
stdio: stdio,
|
||||
run: runMake,
|
||||
}, {
|
||||
flag: "--finalize-bazel-metrics",
|
||||
description: "finalize b metrics and upload",
|
||||
config: build.UploadOnlyConfig,
|
||||
stdio: stdio,
|
||||
// Finalize-bazel-metrics mode updates metrics files and calls the metrics
|
||||
// uploader. This marks the end of a b invocation.
|
||||
run: finalizeBazelMetrics,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -199,7 +191,6 @@ func main() {
|
|||
soongMetricsFile := filepath.Join(logsDir, c.logsPrefix+"soong_metrics")
|
||||
rbeMetricsFile := filepath.Join(logsDir, c.logsPrefix+"rbe_metrics.pb")
|
||||
bp2buildMetricsFile := filepath.Join(logsDir, c.logsPrefix+"bp2build_metrics.pb")
|
||||
bazelMetricsFile := filepath.Join(logsDir, c.logsPrefix+"bazel_metrics.pb")
|
||||
soongBuildMetricsFile := filepath.Join(logsDir, c.logsPrefix+"soong_build_metrics.pb")
|
||||
|
||||
metricsFiles := []string{
|
||||
|
@ -207,7 +198,6 @@ func main() {
|
|||
rbeMetricsFile, // high level metrics related to remote build execution.
|
||||
bp2buildMetricsFile, // high level metrics related to bp2build.
|
||||
soongMetricsFile, // high level metrics related to this build system.
|
||||
bazelMetricsFile, // high level metrics related to bazel execution
|
||||
soongBuildMetricsFile, // high level metrics related to soong build(except bp2build)
|
||||
config.BazelMetricsDir(), // directory that contains a set of bazel metrics.
|
||||
}
|
||||
|
@ -247,10 +237,9 @@ func logAndSymlinkSetup(buildCtx build.Context, config build.Config) {
|
|||
soongMetricsFile := filepath.Join(logsDir, logsPrefix+"soong_metrics")
|
||||
bp2buildMetricsFile := filepath.Join(logsDir, logsPrefix+"bp2build_metrics.pb")
|
||||
soongBuildMetricsFile := filepath.Join(logsDir, logsPrefix+"soong_build_metrics.pb")
|
||||
bazelMetricsFile := filepath.Join(logsDir, logsPrefix+"bazel_metrics.pb")
|
||||
|
||||
//Delete the stale metrics files
|
||||
staleFileSlice := []string{buildErrorFile, rbeMetricsFile, soongMetricsFile, bp2buildMetricsFile, soongBuildMetricsFile, bazelMetricsFile}
|
||||
staleFileSlice := []string{buildErrorFile, rbeMetricsFile, soongMetricsFile, bp2buildMetricsFile, soongBuildMetricsFile}
|
||||
if err := deleteStaleMetrics(staleFileSlice); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
@ -701,28 +690,3 @@ func setMaxFiles(ctx build.Context) {
|
|||
ctx.Println("Failed to increase file limit:", err)
|
||||
}
|
||||
}
|
||||
|
||||
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")
|
||||
|
||||
//read file into proto
|
||||
data, err := os.ReadFile(soongMetricsFile)
|
||||
if err != nil {
|
||||
ctx.Fatal(err)
|
||||
}
|
||||
met := ctx.ContextImpl.Metrics
|
||||
|
||||
err = met.UpdateTotalRealTimeAndNonZeroExit(data, config.BazelExitCode())
|
||||
if err != nil {
|
||||
ctx.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -205,21 +205,6 @@ func loadEnvConfig(ctx Context, config *configImpl, bc string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func UploadOnlyConfig(ctx Context, args ...string) Config {
|
||||
ret := &configImpl{
|
||||
environ: OsEnvironment(),
|
||||
sandboxConfig: &SandboxConfig{},
|
||||
}
|
||||
ret.parseArgs(ctx, args)
|
||||
srcDir := absPath(ctx, ".")
|
||||
bc := os.Getenv("ANDROID_BUILD_ENVIRONMENT_CONFIG")
|
||||
if err := loadEnvConfig(ctx, ret, bc); err != nil {
|
||||
ctx.Fatalln("Failed to parse env config files: %v", err)
|
||||
}
|
||||
ret.metricsUploader = GetMetricsUploader(srcDir, ret.environ)
|
||||
return Config{ret}
|
||||
}
|
||||
|
||||
func NewConfig(ctx Context, args ...string) Config {
|
||||
ret := &configImpl{
|
||||
environ: OsEnvironment(),
|
||||
|
@ -822,16 +807,6 @@ func (c *configImpl) parseArgs(ctx Context, args []string) {
|
|||
}
|
||||
} else if arg == "--ensure-allowlist-integrity" {
|
||||
c.ensureAllowlistIntegrity = true
|
||||
} else if strings.HasPrefix(arg, "--bazel-exit-code=") {
|
||||
bazelExitCodeStr := strings.TrimPrefix(arg, "--bazel-exit-code=")
|
||||
val, err := strconv.Atoi(bazelExitCodeStr)
|
||||
if err == nil {
|
||||
c.bazelExitCode = int32(val)
|
||||
} else {
|
||||
ctx.Fatalf("Error parsing bazel-exit-code", err)
|
||||
}
|
||||
} else if strings.HasPrefix(arg, "--bes-id=") {
|
||||
c.besId = strings.TrimPrefix(arg, "--bes-id=")
|
||||
} else if len(arg) > 0 && arg[0] == '-' {
|
||||
parseArgNum := func(def int) int {
|
||||
if len(arg) > 2 {
|
||||
|
|
|
@ -32,7 +32,6 @@ package metrics
|
|||
// of what an event is and how the metrics system is a stack based system.
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
@ -228,20 +227,6 @@ func (m *Metrics) SetBuildDateTime(buildTimestamp time.Time) {
|
|||
m.metrics.BuildDateTimestamp = proto.Int64(buildTimestamp.UnixNano() / int64(time.Second))
|
||||
}
|
||||
|
||||
func (m *Metrics) UpdateTotalRealTimeAndNonZeroExit(data []byte, bazelExitCode int32) error {
|
||||
if err := proto.Unmarshal(data, &m.metrics); err != nil {
|
||||
return fmt.Errorf("Failed to unmarshal proto: %w", err)
|
||||
}
|
||||
startTime := *m.metrics.Total.StartTime
|
||||
endTime := uint64(time.Now().UnixNano())
|
||||
|
||||
*m.metrics.Total.RealTime = *proto.Uint64(endTime - startTime)
|
||||
|
||||
bazelError := bazelExitCode != 0
|
||||
m.metrics.NonZeroExit = proto.Bool(bazelError)
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetBuildCommand adds the build command specified by the user to the
|
||||
// list of collected metrics.
|
||||
func (m *Metrics) SetBuildCommand(cmd []string) {
|
||||
|
|
Loading…
Reference in a new issue