diff options
author | 2023-04-25 08:56:54 +0000 | |
---|---|---|
committer | 2023-04-26 12:26:39 +0000 | |
commit | 822d8ac6b1029bdd84786fe3721d8138ab7e36d2 (patch) | |
tree | abc24cff66a7c77785a128c309e4bed5ddf33042 | |
parent | 54d4f60748123981f088907639e38202347e4fe2 (diff) |
Report Odrefresh BCP compilation type to StatsD
Bug: 279004055
Test: atest art_standalone_odrefresh_tests
Change-Id: If563943ddbce706dc81fda7a11c78ac4c067fa9a
-rw-r--r-- | odrefresh/odr_metrics.h | 12 | ||||
-rw-r--r-- | odrefresh/odr_metrics_record.h | 2 | ||||
-rw-r--r-- | odrefresh/odr_statslog_android.cc | 138 | ||||
-rw-r--r-- | runtime/exec_utils.h | 4 |
4 files changed, 37 insertions, 119 deletions
diff --git a/odrefresh/odr_metrics.h b/odrefresh/odr_metrics.h index 94414f89d9..4605277df9 100644 --- a/odrefresh/odr_metrics.h +++ b/odrefresh/odr_metrics.h @@ -34,7 +34,8 @@ class OdrMetrics final { public: // Enumeration used to track the latest stage reached running odrefresh. // - // These values mirror those in OdrefreshReported::Stage in frameworks/proto_logging/atoms.proto. + // These values mirror those in OdrefreshReported::Stage in + // frameworks/proto_logging/atoms/art/odrefresh_extension_atoms.proto. // NB There are gaps between the values in case an additional stages are introduced. enum class Stage : uint8_t { kUnknown = 0, @@ -48,7 +49,8 @@ class OdrMetrics final { // Enumeration describing the overall status, processing stops on the first error discovered. // - // These values mirror those in OdrefreshReported::Status in frameworks/proto_logging/atoms.proto. + // These values mirror those in OdrefreshReported::Status in + // frameworks/proto_logging/atoms/art/odrefresh_extension_atoms.proto. enum class Status : uint8_t { kUnknown = 0, kOK = 1, @@ -66,7 +68,7 @@ class OdrMetrics final { // Enumeration describing the cause of compilation (if any) in odrefresh. // // These values mirror those in OdrefreshReported::Trigger in - // frameworks/proto_logging/atoms.proto. + // frameworks/proto_logging/atoms/art/odrefresh_extension_atoms.proto. enum class Trigger : uint8_t { kUnknown = 0, kApexVersionMismatch = 1, @@ -74,6 +76,10 @@ class OdrMetrics final { kMissingArtifacts = 3, }; + // Enumeration describing the type of boot classpath compilation in odrefresh. + // + // These values mirror those in OdrefreshReported::BcpCompilationType in + // frameworks/proto_logging/atoms/art/odrefresh_extension_atoms.proto. enum class BcpCompilationType : uint8_t { kUnknown = 0, // Compiles for both the primary boot image and the mainline extension. diff --git a/odrefresh/odr_metrics_record.h b/odrefresh/odr_metrics_record.h index 41dea3e199..4b18edb6d6 100644 --- a/odrefresh/odr_metrics_record.h +++ b/odrefresh/odr_metrics_record.h @@ -31,7 +31,7 @@ namespace odrefresh { constexpr const char* kOdrefreshMetricsFile = "/data/misc/odrefresh/odrefresh-metrics.xml"; // Initial OdrefreshMetrics version -static constexpr int32_t kOdrefreshMetricsVersion = 3; +static constexpr int32_t kOdrefreshMetricsVersion = 4; // Constant value used in ExecResult when the process was not run at all. // Mirrors EXEC_RESULT_STATUS_NOT_RUN contained in frameworks/proto_logging/atoms.proto. diff --git a/odrefresh/odr_statslog_android.cc b/odrefresh/odr_statslog_android.cc index 5e25929f6d..fe2d121b6c 100644 --- a/odrefresh/odr_statslog_android.cc +++ b/odrefresh/odr_statslog_android.cc @@ -35,71 +35,6 @@ using android::base::StringPrintf; namespace { -// Convert bare value from art::metrics::Stage to value defined in atoms.proto. -int32_t TranslateStage(int32_t art_metrics_stage) { - switch (static_cast<OdrMetrics::Stage>(art_metrics_stage)) { - case OdrMetrics::Stage::kUnknown: - return metrics::statsd::ODREFRESH_REPORTED__STAGE_REACHED__STAGE_UNKNOWN; - case OdrMetrics::Stage::kCheck: - return metrics::statsd::ODREFRESH_REPORTED__STAGE_REACHED__STAGE_CHECK; - case OdrMetrics::Stage::kPreparation: - return metrics::statsd::ODREFRESH_REPORTED__STAGE_REACHED__STAGE_PREPARATION; - case OdrMetrics::Stage::kPrimaryBootClasspath: - return metrics::statsd::ODREFRESH_REPORTED__STAGE_REACHED__STAGE_PRIMARY_BOOT_CLASSPATH; - case OdrMetrics::Stage::kSecondaryBootClasspath: - return metrics::statsd::ODREFRESH_REPORTED__STAGE_REACHED__STAGE_SECONDARY_BOOT_CLASSPATH; - case OdrMetrics::Stage::kSystemServerClasspath: - return metrics::statsd::ODREFRESH_REPORTED__STAGE_REACHED__STAGE_SYSTEM_SERVER_CLASSPATH; - case OdrMetrics::Stage::kComplete: - return metrics::statsd::ODREFRESH_REPORTED__STAGE_REACHED__STAGE_COMPLETE; - } - - LOG(ERROR) << "Unknown stage value: " << art_metrics_stage; - return -1; -} - -// Convert bare value from art::metrics::Status to value defined in atoms.proto. -int32_t TranslateStatus(int32_t art_metrics_status) { - switch (static_cast<OdrMetrics::Status>(art_metrics_status)) { - case OdrMetrics::Status::kUnknown: - return metrics::statsd::ODREFRESH_REPORTED__STATUS__STATUS_UNKNOWN; - case OdrMetrics::Status::kOK: - return metrics::statsd::ODREFRESH_REPORTED__STATUS__STATUS_OK; - case OdrMetrics::Status::kNoSpace: - return metrics::statsd::ODREFRESH_REPORTED__STATUS__STATUS_NO_SPACE; - case OdrMetrics::Status::kIoError: - return metrics::statsd::ODREFRESH_REPORTED__STATUS__STATUS_IO_ERROR; - case OdrMetrics::Status::kDex2OatError: - return metrics::statsd::ODREFRESH_REPORTED__STATUS__STATUS_DEX2OAT_ERROR; - case OdrMetrics::Status::kStagingFailed: - return metrics::statsd::ODREFRESH_REPORTED__STATUS__STATUS_STAGING_FAILED; - case OdrMetrics::Status::kInstallFailed: - return metrics::statsd::ODREFRESH_REPORTED__STATUS__STATUS_INSTALL_FAILED; - case OdrMetrics::Status::kDalvikCachePermissionDenied: - return metrics::statsd::ODREFRESH_REPORTED__STATUS__STATUS_DALVIK_CACHE_PERMISSION_DENIED; - } - - LOG(ERROR) << "Unknown status value: " << art_metrics_status; - return -1; -} - -// Convert bare value from art::metrics::Trigger to value defined in atoms.proto. -int32_t TranslateTrigger(int32_t art_metrics_trigger) { - switch (static_cast<OdrMetrics::Trigger>(art_metrics_trigger)) { - case OdrMetrics::Trigger::kUnknown: - return metrics::statsd::ODREFRESH_REPORTED__TRIGGER__TRIGGER_UNKNOWN; - case OdrMetrics::Trigger::kApexVersionMismatch: - return metrics::statsd::ODREFRESH_REPORTED__TRIGGER__TRIGGER_APEX_VERSION_MISMATCH; - case OdrMetrics::Trigger::kDexFilesChanged: - return metrics::statsd::ODREFRESH_REPORTED__TRIGGER__TRIGGER_DEX_FILES_CHANGED; - case OdrMetrics::Trigger::kMissingArtifacts: - return metrics::statsd::ODREFRESH_REPORTED__TRIGGER__TRIGGER_MISSING_ARTIFACTS; - } - - LOG(ERROR) << "Unknown trigger value: " << art_metrics_trigger; - return -1; -} - bool ReadValues(const char* metrics_file, /*out*/ OdrMetricsRecord* record, /*out*/ std::string* error_msg) { @@ -111,30 +46,6 @@ bool ReadValues(const char* metrics_file, return false; } - // - // Convert values defined as enums to their statsd values. - // - - record->trigger = TranslateTrigger(record->trigger); - if (record->trigger < 0) { - *error_msg = "failed to parse trigger."; - return false; - } - - record->stage_reached = TranslateStage(record->stage_reached); - if (record->stage_reached < 0) { - *error_msg = "failed to parse stage_reached."; - return false; - } - - record->status = TranslateStatus(record->status); - if (record->status < 0) { - *error_msg = "failed to parse status."; - return false; - } - - // TODO(b/279004055): Translate BCP compilation types. - return true; } @@ -148,30 +59,31 @@ bool UploadStatsIfAvailable(/*out*/std::string* error_msg) { // Write values to statsd. The order of values passed is the same as the order of the // fields in OdrMetricsRecord. - // TODO(b/279004055): Write BCP compilation types. - int bytes_written = art::metrics::statsd::stats_write( - metrics::statsd::ODREFRESH_REPORTED, - record.art_apex_version, - record.trigger, - record.stage_reached, - record.status, - record.primary_bcp_compilation_millis / 1000, - record.secondary_bcp_compilation_millis / 1000, - record.system_server_compilation_millis / 1000, - record.cache_space_free_start_mib, - record.cache_space_free_end_mib, - record.primary_bcp_compilation_millis, - record.secondary_bcp_compilation_millis, - record.system_server_compilation_millis, - record.primary_bcp_dex2oat_result.status, - record.primary_bcp_dex2oat_result.exit_code, - record.primary_bcp_dex2oat_result.signal, - record.secondary_bcp_dex2oat_result.status, - record.secondary_bcp_dex2oat_result.exit_code, - record.secondary_bcp_dex2oat_result.signal, - record.system_server_dex2oat_result.status, - record.system_server_dex2oat_result.exit_code, - record.system_server_dex2oat_result.signal); + int bytes_written = + art::metrics::statsd::stats_write(metrics::statsd::ODREFRESH_REPORTED, + record.art_apex_version, + record.trigger, + record.stage_reached, + record.status, + record.primary_bcp_compilation_millis / 1000, + record.secondary_bcp_compilation_millis / 1000, + record.system_server_compilation_millis / 1000, + record.cache_space_free_start_mib, + record.cache_space_free_end_mib, + record.primary_bcp_compilation_millis, + record.secondary_bcp_compilation_millis, + record.system_server_compilation_millis, + record.primary_bcp_dex2oat_result.status, + record.primary_bcp_dex2oat_result.exit_code, + record.primary_bcp_dex2oat_result.signal, + record.secondary_bcp_dex2oat_result.status, + record.secondary_bcp_dex2oat_result.exit_code, + record.secondary_bcp_dex2oat_result.signal, + record.system_server_dex2oat_result.status, + record.system_server_dex2oat_result.exit_code, + record.system_server_dex2oat_result.signal, + record.primary_bcp_compilation_type, + record.secondary_bcp_compilation_type); if (bytes_written <= 0) { *error_msg = android::base::StringPrintf("stats_write returned %d", bytes_written); return false; diff --git a/runtime/exec_utils.h b/runtime/exec_utils.h index 11ab579b09..b83722fd62 100644 --- a/runtime/exec_utils.h +++ b/runtime/exec_utils.h @@ -44,8 +44,8 @@ struct ExecCallbacks { }; struct ExecResult { - // This struct needs to be in sync with the ExecResultStatus enum contained within - // the OdrefreshReported atom in frameworks/proto_logging/atoms.proto. + // This struct needs to be in sync with the ExecResultStatus enum contained within the + // OdrefreshReported atom in frameworks/proto_logging/atoms/art/odrefresh_extension_atoms.proto. enum Status { // Unable to get the status. kUnknown = 0, |