Write boot image status to statsd.
Bug: 257028435
Test: adb shell cmd stats print-stats | grep 550
Change-Id: I5bf7e64b64cfdd6f8ea5a23d8c024b94bf01a133
diff --git a/runtime/metrics/statsd.cc b/runtime/metrics/statsd.cc
index 203b72e..036f667 100644
--- a/runtime/metrics/statsd.cc
+++ b/runtime/metrics/statsd.cc
@@ -19,6 +19,9 @@
#include "arch/instruction_set.h"
#include "base/compiler_filter.h"
#include "base/metrics/metrics.h"
+#include "gc/heap.h"
+#include "gc/space/image_space.h"
+#include "runtime.h"
#include "statslog_art.h"
#pragma clang diagnostic push
@@ -282,6 +285,20 @@
std::unique_ptr<MetricsBackend> CreateStatsdBackend() { return std::make_unique<StatsdBackend>(); }
+void ReportDeviceMetrics() {
+ Runtime* runtime = Runtime::Current();
+ int32_t boot_image_status;
+ if (runtime->GetHeap()->HasBootImageSpace() && !runtime->HasImageWithProfile()) {
+ boot_image_status = statsd::ART_DEVICE_DATUM_REPORTED__BOOT_IMAGE_STATUS__STATUS_FULL;
+ } else if (runtime->GetHeap()->HasBootImageSpace() &&
+ runtime->GetHeap()->GetBootImageSpaces()[0]->GetProfileFiles().empty()) {
+ boot_image_status = statsd::ART_DEVICE_DATUM_REPORTED__BOOT_IMAGE_STATUS__STATUS_MINIMAL;
+ } else {
+ boot_image_status = statsd::ART_DEVICE_DATUM_REPORTED__BOOT_IMAGE_STATUS__STATUS_NONE;
+ }
+ statsd::stats_write(statsd::ART_DEVICE_DATUM_REPORTED, boot_image_status);
+}
+
} // namespace metrics
} // namespace art
diff --git a/runtime/metrics/statsd.h b/runtime/metrics/statsd.h
index a99d510..cb84825 100644
--- a/runtime/metrics/statsd.h
+++ b/runtime/metrics/statsd.h
@@ -27,8 +27,10 @@
// Statsd is only supported on Android
#ifdef __ANDROID__
std::unique_ptr<MetricsBackend> CreateStatsdBackend();
+void ReportDeviceMetrics();
#else
inline std::unique_ptr<MetricsBackend> CreateStatsdBackend() { return nullptr; }
+inline void ReportDeviceMetrics() {}
#endif
} // namespace metrics
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index b603e7e..ccbd929 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -102,6 +102,7 @@
#include "jni_id_type.h"
#include "linear_alloc.h"
#include "memory_representation.h"
+#include "metrics/statsd.h"
#include "mirror/array.h"
#include "mirror/class-alloc-inl.h"
#include "mirror/class-inl.h"
@@ -1216,12 +1217,13 @@
}
if (Runtime::Current()->IsSystemServer()) {
std::string err;
- ScopedTrace tr("odrefresh stats logging");
+ ScopedTrace tr("odrefresh and device stats logging");
ScopedThreadSuspension sts(Thread::Current(), ThreadState::kNative);
// Report stats if available. This should be moved into ART Services when they are ready.
if (!odrefresh::UploadStatsIfAvailable(&err)) {
LOG(WARNING) << "Failed to upload odrefresh metrics: " << err;
}
+ metrics::ReportDeviceMetrics();
}
if (LIKELY(automatically_set_jni_ids_indirection_) && CanSetJniIdType()) {