diff options
Diffstat (limited to 'android/metrics.go')
-rw-r--r-- | android/metrics.go | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/android/metrics.go b/android/metrics.go index 1580f82b1..ecda0266d 100644 --- a/android/metrics.go +++ b/android/metrics.go @@ -32,8 +32,13 @@ type SoongMetrics struct { Variants int } -func ReadSoongMetrics(config Config) SoongMetrics { - return config.Get(soongMetricsOnceKey).(SoongMetrics) +func readSoongMetrics(config Config) (SoongMetrics, bool) { + soongMetrics, ok := config.Peek(soongMetricsOnceKey) + if ok { + return soongMetrics.(SoongMetrics), true + } else { + return SoongMetrics{}, false + } } func init() { @@ -60,9 +65,11 @@ func (soongMetricsSingleton) GenerateBuildActions(ctx SingletonContext) { func collectMetrics(config Config, eventHandler metrics.EventHandler) *soong_metrics_proto.SoongBuildMetrics { metrics := &soong_metrics_proto.SoongBuildMetrics{} - soongMetrics := ReadSoongMetrics(config) - metrics.Modules = proto.Uint32(uint32(soongMetrics.Modules)) - metrics.Variants = proto.Uint32(uint32(soongMetrics.Variants)) + soongMetrics, ok := readSoongMetrics(config) + if ok { + metrics.Modules = proto.Uint32(uint32(soongMetrics.Modules)) + metrics.Variants = proto.Uint32(uint32(soongMetrics.Variants)) + } memStats := runtime.MemStats{} runtime.ReadMemStats(&memStats) |