summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Eric Holk <eholk@google.com> 2021-01-27 23:41:45 +0000
committer Treehugger Robot <treehugger-gerrit@google.com> 2021-02-01 19:09:57 +0000
commit480d98182efa33179f1773c791dc8f4bed62ef2b (patch)
treee352691c80cd341dcfb55ef31d3f2044362c9416
parent10592e30a959d4ebe90f5ba4b6237ec0cacddc6c (diff)
[metrics] Move core metrics code to libartbase
We would like to be able to use ART's metrics system in places where we do not have access to the runtime. This CL splits the metrics code into the core implementation of the counters and histograms and the background reporting thread. The reporting thread was the only part that had dependencies on the runtime, so this remains in the runtime. The bulk of the metrics code moves to libartbase so that it can be used in more contexts. Bug: 178099697 Test: m test-art-host-gtest Change-Id: I26a4fe326371686d5857ad49ba98569f5c55f84a
-rw-r--r--libartbase/Android.bp2
-rw-r--r--libartbase/base/metrics/metrics.h (renamed from runtime/metrics/metrics.h)73
-rw-r--r--libartbase/base/metrics/metrics_common.cc (renamed from runtime/metrics/metrics.cc)134
-rw-r--r--libartbase/base/metrics/metrics_test.cc (renamed from runtime/metrics/metrics_test.cc)0
-rw-r--r--libartbase/base/metrics/metrics_test.h (renamed from runtime/metrics/metrics_test.h)6
-rw-r--r--openjdkjvmti/ti_thread.cc2
-rw-r--r--runtime/Android.bp3
-rw-r--r--runtime/metrics_reporter.cc145
-rw-r--r--runtime/metrics_reporter.h100
-rw-r--r--runtime/runtime.h3
-rw-r--r--runtime/verifier/method_verifier_test.cc2
11 files changed, 263 insertions, 207 deletions
diff --git a/libartbase/Android.bp b/libartbase/Android.bp
index 82064bdf5e..60dcf17932 100644
--- a/libartbase/Android.bp
+++ b/libartbase/Android.bp
@@ -36,6 +36,7 @@ cc_defaults {
"base/memory_region.cc",
"base/mem_map.cc",
// "base/mem_map_fuchsia.cc", put in target when fuchsia supported by soong
+ "base/metrics/metrics_common.cc",
"base/os_linux.cc",
"base/runtime_debug.cc",
"base/safe_copy.cc",
@@ -255,6 +256,7 @@ art_cc_test {
"base/membarrier_test.cc",
"base/memory_region_test.cc",
"base/mem_map_test.cc",
+ "base/metrics/metrics_test.cc",
"base/safe_copy_test.cc",
"base/scoped_flock_test.cc",
"base/time_utils_test.cc",
diff --git a/runtime/metrics/metrics.h b/libartbase/base/metrics/metrics.h
index 1c0339434e..bab58126c8 100644
--- a/runtime/metrics/metrics.h
+++ b/libartbase/base/metrics/metrics.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef ART_RUNTIME_METRICS_METRICS_H_
-#define ART_RUNTIME_METRICS_METRICS_H_
+#ifndef ART_LIBARTBASE_BASE_METRICS_METRICS_H_
+#define ART_LIBARTBASE_BASE_METRICS_METRICS_H_
#include <stdint.h>
@@ -28,7 +28,6 @@
#include <vector>
#include "android-base/logging.h"
-#include "base/message_queue.h"
#include "base/time_utils.h"
#pragma clang diagnostic push
@@ -376,75 +375,9 @@ class ArtMetrics {
// Returns a human readable name for the given DatumId.
std::string DatumName(DatumId datum);
-// Defines the set of options for how metrics reporting happens.
-struct ReportingConfig {
- static ReportingConfig FromRuntimeArguments(const RuntimeArgumentMap& args);
-
- // Causes metrics to be written to the log, which makes them show up in logcat.
- bool dump_to_logcat{false};
-
- // If set, provides a file name to enable metrics logging to a file.
- std::optional<std::string> dump_to_file;
-
- // Indicates whether to report the final state of metrics on shutdown.
- //
- // Note that reporting only happens if some output, such as logcat, is enabled.
- bool report_metrics_on_shutdown{true};
-
- // If set, metrics will be reported every time this many seconds elapses.
- std::optional<unsigned int> periodic_report_seconds;
-
- // Returns whether any options are set that enables metrics reporting.
- constexpr bool ReportingEnabled() const { return dump_to_logcat || dump_to_file.has_value(); }
-
- // Returns whether any options are set that requires a background reporting thread.
- constexpr bool BackgroundReportingEnabled() const {
- return ReportingEnabled() && periodic_report_seconds.has_value();
- }
-};
-
-// MetricsReporter handles periodically reporting ART metrics.
-class MetricsReporter {
- public:
- // Creates a MetricsReporter instance that matches the options selected in ReportingConfig.
- static std::unique_ptr<MetricsReporter> Create(ReportingConfig config, Runtime* runtime);
-
- ~MetricsReporter();
-
- // Creates and runs the background reporting thread.
- void MaybeStartBackgroundThread();
-
- // Sends a request to the background thread to shutdown.
- void MaybeStopBackgroundThread();
-
- static constexpr const char* kBackgroundThreadName = "Metrics Background Reporting Thread";
-
- private:
- MetricsReporter(ReportingConfig config, Runtime* runtime);
-
- // The background reporting thread main loop.
- void BackgroundThreadRun();
-
- // Calls messages_.SetTimeout if needed.
- void MaybeResetTimeout();
-
- // Outputs the current state of the metrics to the destination set by config_.
- void ReportMetrics() const;
-
- const ReportingConfig config_;
- Runtime* runtime_;
-
- std::optional<std::thread> thread_;
-
- // A message indicating that the reporting thread should shut down.
- struct ShutdownRequestedMessage {};
-
- MessageQueue<ShutdownRequestedMessage> messages_;
-};
-
} // namespace metrics
} // namespace art
#pragma clang diagnostic pop // -Wconversion
-#endif // ART_RUNTIME_METRICS_METRICS_H_
+#endif // ART_LIBARTBASE_BASE_METRICS_METRICS_H_
diff --git a/runtime/metrics/metrics.cc b/libartbase/base/metrics/metrics_common.cc
index f0b2421318..a36f106f12 100644
--- a/runtime/metrics/metrics.cc
+++ b/libartbase/base/metrics/metrics_common.cc
@@ -14,23 +14,15 @@
* limitations under the License.
*/
-#include "metrics.h"
-
#include <sstream>
-#include "android-base/file.h"
#include "android-base/logging.h"
#include "base/macros.h"
-#include "base/scoped_flock.h"
-#include "runtime.h"
-#include "runtime_options.h"
-#include "thread-current-inl.h"
+#include "metrics.h"
#pragma clang diagnostic push
#pragma clang diagnostic error "-Wconversion"
-using android::base::WriteStringToFd;
-
namespace art {
namespace metrics {
@@ -160,19 +152,12 @@ void StreamBackend::ReportCounter(DatumId counter_type, uint64_t value) {
}
void StreamBackend::ReportHistogram(DatumId histogram_type,
- int64_t minimum_value,
- int64_t maximum_value,
+ int64_t minimum_value_,
+ int64_t maximum_value_,
const std::vector<uint32_t>& buckets) {
- os_ << DatumName(histogram_type) << ": range = " << minimum_value << "..." << maximum_value
- << "\n";
- std::vector<uint32_t> cumulative_buckets = CumulativeBuckets(buckets);
- std::pair<int64_t, int64_t> confidence_interval = HistogramConfidenceInterval(
- /*interval=*/0.99, minimum_value, maximum_value, cumulative_buckets);
- os_ << " 99% confidence interval: " << confidence_interval.first << "..."
- << confidence_interval.second << "\n";
-
+ os_ << DatumName(histogram_type) << ": range = " << minimum_value_ << "..." << maximum_value_;
if (buckets.size() > 0) {
- os_ << " buckets: ";
+ os_ << ", buckets: ";
bool first = true;
for (const auto& count : buckets) {
if (!first) {
@@ -187,115 +172,6 @@ void StreamBackend::ReportHistogram(DatumId histogram_type,
}
}
-std::unique_ptr<MetricsReporter> MetricsReporter::Create(ReportingConfig config, Runtime* runtime) {
- // We can't use std::make_unique here because the MetricsReporter constructor is private.
- return std::unique_ptr<MetricsReporter>{new MetricsReporter{std::move(config), runtime}};
-}
-
-MetricsReporter::MetricsReporter(ReportingConfig config, Runtime* runtime)
- : config_{std::move(config)}, runtime_{runtime} {}
-
-MetricsReporter::~MetricsReporter() { MaybeStopBackgroundThread(); }
-
-void MetricsReporter::MaybeStartBackgroundThread() {
- if (config_.BackgroundReportingEnabled()) {
- CHECK(!thread_.has_value());
-
- thread_.emplace(&MetricsReporter::BackgroundThreadRun, this);
- }
-}
-
-void MetricsReporter::MaybeStopBackgroundThread() {
- if (thread_.has_value()) {
- messages_.SendMessage(ShutdownRequestedMessage{});
- thread_->join();
- }
- // Do one final metrics report, if enabled.
- if (config_.report_metrics_on_shutdown) {
- ReportMetrics();
- }
-}
-
-void MetricsReporter::BackgroundThreadRun() {
- LOG_STREAM(DEBUG) << "Metrics reporting thread started";
-
- // AttachCurrentThread is needed so we can safely use the ART concurrency primitives within the
- // messages_ MessageQueue.
- runtime_->AttachCurrentThread(kBackgroundThreadName,
- /*as_daemon=*/true,
- runtime_->GetSystemThreadGroup(),
- /*create_peer=*/true);
- bool running = true;
-
- MaybeResetTimeout();
-
- while (running) {
- messages_.SwitchReceive(
- [&]([[maybe_unused]] ShutdownRequestedMessage message) {
- LOG_STREAM(DEBUG) << "Shutdown request received";
- running = false;
- },
- [&]([[maybe_unused]] TimeoutExpiredMessage message) {
- LOG_STREAM(DEBUG) << "Timer expired, reporting metrics";
-
- ReportMetrics();
-
- MaybeResetTimeout();
- });
- }
-
- runtime_->DetachCurrentThread();
- LOG_STREAM(DEBUG) << "Metrics reporting thread terminating";
-}
-
-void MetricsReporter::MaybeResetTimeout() {
- if (config_.periodic_report_seconds.has_value()) {
- messages_.SetTimeout(SecondsToMs(config_.periodic_report_seconds.value()));
- }
-}
-
-void MetricsReporter::ReportMetrics() const {
- if (config_.dump_to_logcat) {
- LOG_STREAM(INFO) << "\n*** ART internal metrics ***\n\n";
- // LOG_STREAM(INFO) destroys the stream at the end of the statement, which makes it tricky pass
- // it to store as a field in StreamBackend. To get around this, we use an immediately-invoked
- // lambda expression to act as a let-binding, letting us access the stream for long enough to
- // dump the metrics.
- [this](std::ostream& os) {
- StreamBackend backend{os};
- runtime_->GetMetrics()->ReportAllMetrics(&backend);
- }(LOG_STREAM(INFO));
- LOG_STREAM(INFO) << "\n*** Done dumping ART internal metrics ***\n";
- }
- if (config_.dump_to_file.has_value()) {
- const auto& filename = config_.dump_to_file.value();
- std::ostringstream stream;
- StreamBackend backend{stream};
- runtime_->GetMetrics()->ReportAllMetrics(&backend);
-
- std::string error_message;
- auto file{
- LockedFile::Open(filename.c_str(), O_CREAT | O_WRONLY | O_APPEND, true, &error_message)};
- if (file.get() == nullptr) {
- LOG(WARNING) << "Could open metrics file '" << filename << "': " << error_message;
- } else {
- if (!WriteStringToFd(stream.str(), file.get()->Fd())) {
- PLOG(WARNING) << "Error writing metrics to file";
- }
- }
- }
-}
-
-ReportingConfig ReportingConfig::FromRuntimeArguments(const RuntimeArgumentMap& args) {
- using M = RuntimeArgumentMap;
- return {
- .dump_to_logcat = args.Exists(M::WriteMetricsToLog),
- .dump_to_file = args.GetOptional(M::WriteMetricsToFile),
- .report_metrics_on_shutdown = !args.Exists(M::DisableFinalMetricsReport),
- .periodic_report_seconds = args.GetOptional(M::MetricsReportingPeriod),
- };
-}
-
} // namespace metrics
} // namespace art
diff --git a/runtime/metrics/metrics_test.cc b/libartbase/base/metrics/metrics_test.cc
index 79684e9ad0..79684e9ad0 100644
--- a/runtime/metrics/metrics_test.cc
+++ b/libartbase/base/metrics/metrics_test.cc
diff --git a/runtime/metrics/metrics_test.h b/libartbase/base/metrics/metrics_test.h
index e074a50308..72ca90e1f1 100644
--- a/runtime/metrics/metrics_test.h
+++ b/libartbase/base/metrics/metrics_test.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef ART_RUNTIME_METRICS_METRICS_TEST_H_
-#define ART_RUNTIME_METRICS_METRICS_TEST_H_
+#ifndef ART_LIBARTBASE_BASE_METRICS_METRICS_TEST_H_
+#define ART_LIBARTBASE_BASE_METRICS_METRICS_TEST_H_
#include "metrics.h"
@@ -82,4 +82,4 @@ std::vector<uint32_t> GetBuckets(
#pragma clang diagnostic pop // -Wconversion
-#endif // ART_RUNTIME_METRICS_METRICS_TEST_H_
+#endif // ART_LIBARTBASE_BASE_METRICS_METRICS_TEST_H_
diff --git a/openjdkjvmti/ti_thread.cc b/openjdkjvmti/ti_thread.cc
index 98a0b9da9b..c9e58094c4 100644
--- a/openjdkjvmti/ti_thread.cc
+++ b/openjdkjvmti/ti_thread.cc
@@ -45,7 +45,7 @@
#include "gc/system_weak.h"
#include "gc_root-inl.h"
#include "jni/jni_internal.h"
-#include "metrics/metrics.h"
+#include "metrics_reporter.h"
#include "mirror/class.h"
#include "mirror/object-inl.h"
#include "mirror/string.h"
diff --git a/runtime/Android.bp b/runtime/Android.bp
index ed2c5ae4bd..8ad00ad3ac 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -156,7 +156,7 @@ libart_cc_defaults {
"linear_alloc.cc",
"managed_stack.cc",
"method_handles.cc",
- "metrics/metrics.cc",
+ "metrics_reporter.cc",
"mirror/array.cc",
"mirror/class.cc",
"mirror/class_ext.cc",
@@ -695,7 +695,6 @@ art_cc_test {
"jni/java_vm_ext_test.cc",
"jni/jni_internal_test.cc",
"method_handles_test.cc",
- "metrics/metrics_test.cc",
"mirror/dex_cache_test.cc",
"mirror/method_type_test.cc",
"mirror/object_test.cc",
diff --git a/runtime/metrics_reporter.cc b/runtime/metrics_reporter.cc
new file mode 100644
index 0000000000..70a03c668b
--- /dev/null
+++ b/runtime/metrics_reporter.cc
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "metrics_reporter.h"
+
+#include "android-base/file.h"
+#include "base/scoped_flock.h"
+#include "runtime.h"
+#include "runtime_options.h"
+#include "thread-current-inl.h"
+
+#pragma clang diagnostic push
+#pragma clang diagnostic error "-Wconversion"
+
+namespace art {
+namespace metrics {
+
+using android::base::WriteStringToFd;
+
+std::unique_ptr<MetricsReporter> MetricsReporter::Create(ReportingConfig config, Runtime* runtime) {
+ // We can't use std::make_unique here because the MetricsReporter constructor is private.
+ return std::unique_ptr<MetricsReporter>{new MetricsReporter{std::move(config), runtime}};
+}
+
+MetricsReporter::MetricsReporter(ReportingConfig config, Runtime* runtime)
+ : config_{std::move(config)}, runtime_{runtime} {}
+
+MetricsReporter::~MetricsReporter() { MaybeStopBackgroundThread(); }
+
+void MetricsReporter::MaybeStartBackgroundThread() {
+ if (config_.BackgroundReportingEnabled()) {
+ CHECK(!thread_.has_value());
+
+ thread_.emplace(&MetricsReporter::BackgroundThreadRun, this);
+ }
+}
+
+void MetricsReporter::MaybeStopBackgroundThread() {
+ if (thread_.has_value()) {
+ messages_.SendMessage(ShutdownRequestedMessage{});
+ thread_->join();
+ }
+ // Do one final metrics report, if enabled.
+ if (config_.report_metrics_on_shutdown) {
+ ReportMetrics();
+ }
+}
+
+void MetricsReporter::BackgroundThreadRun() {
+ LOG_STREAM(DEBUG) << "Metrics reporting thread started";
+
+ // AttachCurrentThread is needed so we can safely use the ART concurrency primitives within the
+ // messages_ MessageQueue.
+ runtime_->AttachCurrentThread(kBackgroundThreadName,
+ /*as_daemon=*/true,
+ runtime_->GetSystemThreadGroup(),
+ /*create_peer=*/true);
+ bool running = true;
+
+ MaybeResetTimeout();
+
+ while (running) {
+ messages_.SwitchReceive(
+ [&]([[maybe_unused]] ShutdownRequestedMessage message) {
+ LOG_STREAM(DEBUG) << "Shutdown request received";
+ running = false;
+ },
+ [&]([[maybe_unused]] TimeoutExpiredMessage message) {
+ LOG_STREAM(DEBUG) << "Timer expired, reporting metrics";
+
+ ReportMetrics();
+
+ MaybeResetTimeout();
+ });
+ }
+
+ runtime_->DetachCurrentThread();
+ LOG_STREAM(DEBUG) << "Metrics reporting thread terminating";
+}
+
+void MetricsReporter::MaybeResetTimeout() {
+ if (config_.periodic_report_seconds.has_value()) {
+ messages_.SetTimeout(SecondsToMs(config_.periodic_report_seconds.value()));
+ }
+}
+
+void MetricsReporter::ReportMetrics() const {
+ if (config_.dump_to_logcat) {
+ LOG_STREAM(INFO) << "\n*** ART internal metrics ***\n\n";
+ // LOG_STREAM(INFO) destroys the stream at the end of the statement, which makes it tricky pass
+ // it to store as a field in StreamBackend. To get around this, we use an immediately-invoked
+ // lambda expression to act as a let-binding, letting us access the stream for long enough to
+ // dump the metrics.
+ [this](std::ostream& os) {
+ StreamBackend backend{os};
+ runtime_->GetMetrics()->ReportAllMetrics(&backend);
+ }(LOG_STREAM(INFO));
+ LOG_STREAM(INFO) << "\n*** Done dumping ART internal metrics ***\n";
+ }
+ if (config_.dump_to_file.has_value()) {
+ const auto& filename = config_.dump_to_file.value();
+ std::ostringstream stream;
+ StreamBackend backend{stream};
+ runtime_->GetMetrics()->ReportAllMetrics(&backend);
+
+ std::string error_message;
+ auto file{
+ LockedFile::Open(filename.c_str(), O_CREAT | O_WRONLY | O_APPEND, true, &error_message)};
+ if (file.get() == nullptr) {
+ LOG(WARNING) << "Could open metrics file '" << filename << "': " << error_message;
+ } else {
+ if (!WriteStringToFd(stream.str(), file.get()->Fd())) {
+ PLOG(WARNING) << "Error writing metrics to file";
+ }
+ }
+ }
+}
+
+ReportingConfig ReportingConfig::FromRuntimeArguments(const RuntimeArgumentMap& args) {
+ using M = RuntimeArgumentMap;
+ return {
+ .dump_to_logcat = args.Exists(M::WriteMetricsToLog),
+ .dump_to_file = args.GetOptional(M::WriteMetricsToFile),
+ .report_metrics_on_shutdown = !args.Exists(M::DisableFinalMetricsReport),
+ .periodic_report_seconds = args.GetOptional(M::MetricsReportingPeriod),
+ };
+}
+
+} // namespace metrics
+} // namespace art
+
+#pragma clang diagnostic pop // -Wconversion
diff --git a/runtime/metrics_reporter.h b/runtime/metrics_reporter.h
new file mode 100644
index 0000000000..a969b71897
--- /dev/null
+++ b/runtime/metrics_reporter.h
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_RUNTIME_METRICS_REPORTER_H_
+#define ART_RUNTIME_METRICS_REPORTER_H_
+
+#include "base/message_queue.h"
+#include "base/metrics/metrics.h"
+
+#pragma clang diagnostic push
+#pragma clang diagnostic error "-Wconversion"
+
+namespace art {
+namespace metrics {
+
+// Defines the set of options for how metrics reporting happens.
+struct ReportingConfig {
+ static ReportingConfig FromRuntimeArguments(const RuntimeArgumentMap& args);
+
+ // Causes metrics to be written to the log, which makes them show up in logcat.
+ bool dump_to_logcat{false};
+
+ // If set, provides a file name to enable metrics logging to a file.
+ std::optional<std::string> dump_to_file;
+
+ // Indicates whether to report the final state of metrics on shutdown.
+ //
+ // Note that reporting only happens if some output, such as logcat, is enabled.
+ bool report_metrics_on_shutdown{true};
+
+ // If set, metrics will be reported every time this many seconds elapses.
+ std::optional<unsigned int> periodic_report_seconds;
+
+ // Returns whether any options are set that enables metrics reporting.
+ constexpr bool ReportingEnabled() const { return dump_to_logcat || dump_to_file.has_value(); }
+
+ // Returns whether any options are set that requires a background reporting thread.
+ constexpr bool BackgroundReportingEnabled() const {
+ return ReportingEnabled() && periodic_report_seconds.has_value();
+ }
+};
+
+// MetricsReporter handles periodically reporting ART metrics.
+class MetricsReporter {
+ public:
+ // Creates a MetricsReporter instance that matches the options selected in ReportingConfig.
+ static std::unique_ptr<MetricsReporter> Create(ReportingConfig config, Runtime* runtime);
+
+ ~MetricsReporter();
+
+ // Creates and runs the background reporting thread.
+ void MaybeStartBackgroundThread();
+
+ // Sends a request to the background thread to shutdown.
+ void MaybeStopBackgroundThread();
+
+ static constexpr const char* kBackgroundThreadName = "Metrics Background Reporting Thread";
+
+ private:
+ MetricsReporter(ReportingConfig config, Runtime* runtime);
+
+ // The background reporting thread main loop.
+ void BackgroundThreadRun();
+
+ // Calls messages_.SetTimeout if needed.
+ void MaybeResetTimeout();
+
+ // Outputs the current state of the metrics to the destination set by config_.
+ void ReportMetrics() const;
+
+ const ReportingConfig config_;
+ Runtime* runtime_;
+
+ std::optional<std::thread> thread_;
+
+ // A message indicating that the reporting thread should shut down.
+ struct ShutdownRequestedMessage {};
+
+ MessageQueue<ShutdownRequestedMessage> messages_;
+};
+
+} // namespace metrics
+} // namespace art
+
+#pragma clang diagnostic pop // -Wconversion
+
+#endif // ART_RUNTIME_METRICS_REPORTER_H_
diff --git a/runtime/runtime.h b/runtime/runtime.h
index 06f05a177e..422c6729dd 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -30,6 +30,7 @@
#include "base/locks.h"
#include "base/macros.h"
#include "base/mem_map.h"
+#include "base/metrics/metrics.h"
#include "base/string_view_cpp20.h"
#include "compat_framework.h"
#include "deoptimization_kind.h"
@@ -40,7 +41,7 @@
#include "jdwp_provider.h"
#include "jni/jni_id_manager.h"
#include "jni_id_type.h"
-#include "metrics/metrics.h"
+#include "metrics_reporter.h"
#include "obj_ptr.h"
#include "offsets.h"
#include "process_state.h"
diff --git a/runtime/verifier/method_verifier_test.cc b/runtime/verifier/method_verifier_test.cc
index 42347151e2..cb523d98ac 100644
--- a/runtime/verifier/method_verifier_test.cc
+++ b/runtime/verifier/method_verifier_test.cc
@@ -21,12 +21,12 @@
#include <memory>
#include "android-base/strings.h"
+#include "base/metrics/metrics_test.h"
#include "base/utils.h"
#include "class_linker-inl.h"
#include "class_verifier.h"
#include "common_runtime_test.h"
#include "dex/dex_file-inl.h"
-#include "metrics/metrics_test.h"
#include "scoped_thread_state_change-inl.h"
#include "verifier_enums.h"