summaryrefslogtreecommitdiff
path: root/ui/metrics/metrics.go
diff options
context:
space:
mode:
author Chris Parsons <cparsons@google.com> 2022-03-03 12:01:40 -0500
committer Chris Parsons <cparsons@google.com> 2022-03-03 15:28:20 -0500
commit53f68ae3b83c49a4cd18ba683bd94783cac9b14b (patch)
treecca6bd9f5e643aa49329da67990cff6e9b3b232b /ui/metrics/metrics.go
parent309ee8d39856e763da0f872d857b3587c916ac4d (diff)
Report mkfile metrics with --mk-metrics
Combined with roboleaf CI changes to pass this flag and subsequent pipeline changes, this will allow basic mkfile metrics to be dashboarded, which will help track mk2bp progress. Bug: 217764943 Test: manual; verified mk_metrics.pb is generated iff --mk-metrics is specified, used printproto on result Change-Id: I348994b4d7e3479d0dc04de0276b94a702aac95b
Diffstat (limited to 'ui/metrics/metrics.go')
-rw-r--r--ui/metrics/metrics.go32
1 files changed, 27 insertions, 5 deletions
diff --git a/ui/metrics/metrics.go b/ui/metrics/metrics.go
index 80f8c1ad0..6f1ed6032 100644
--- a/ui/metrics/metrics.go
+++ b/ui/metrics/metrics.go
@@ -41,6 +41,7 @@ import (
"google.golang.org/protobuf/proto"
soong_metrics_proto "android/soong/ui/metrics/metrics_proto"
+ mk_metrics_proto "android/soong/ui/metrics/mk_metrics_proto"
)
const (
@@ -62,14 +63,22 @@ const (
Total = "total"
)
-// Metrics is a struct that stores collected metrics during the course
-// of a build which later is dumped to a MetricsBase protobuf file.
-// See ui/metrics/metrics_proto/metrics.proto for further details
-// on what information is collected.
+// Metrics is a struct that stores collected metrics during the course of a
+// build. It is later dumped to protobuf files. See underlying metrics protos
+// for further details on what information is collected.
type Metrics struct {
- // The protobuf message that is later written to the file.
+ // Protobuf containing various top-level build metrics. These include:
+ // 1. Build identifiers (ex: branch ID, requested product, hostname,
+ // originating command)
+ // 2. Per-subprocess top-level metrics (ex: ninja process IO and runtime).
+ // Note that, since these metrics are reported by soong_ui, there is little
+ // insight that can be provided into performance breakdowns of individual
+ // subprocesses.
metrics soong_metrics_proto.MetricsBase
+ // Protobuf containing metrics pertaining to number of makefiles in a build.
+ mkMetrics mk_metrics_proto.MkMetrics
+
// A list of pending build events.
EventTracer *EventTracer
}
@@ -78,11 +87,24 @@ type Metrics struct {
func New() (metrics *Metrics) {
m := &Metrics{
metrics: soong_metrics_proto.MetricsBase{},
+ mkMetrics: mk_metrics_proto.MkMetrics{},
EventTracer: &EventTracer{},
}
return m
}
+func (m *Metrics) SetTotalMakefiles(total int) {
+ m.mkMetrics.TotalMakefiles = uint32(total)
+}
+
+func (m *Metrics) SetToplevelMakefiles(total int) {
+ m.mkMetrics.ToplevelMakefiles = uint32(total)
+}
+
+func (m *Metrics) DumpMkMetrics(outPath string) {
+ shared.Save(&m.mkMetrics, outPath)
+}
+
// SetTimeMetrics stores performance information from an executed block of
// code.
func (m *Metrics) SetTimeMetrics(perf soong_metrics_proto.PerfInfo) {