summaryrefslogtreecommitdiffstats
path: root/bootstat
diff options
context:
space:
mode:
authorJames Hawkins <jhawkins@google.com>2017-01-31 11:42:24 -0800
committerJames Hawkins <jhawkins@google.com>2017-01-31 11:42:24 -0800
commit9aec926f866f54a311bd898b5f51188f9890a357 (patch)
tree08b5f51a1f60e3e3df41c27d49e240867e537864 /bootstat
parent7dde4fa4e2a4949c7d7e6a8376b5c9bda26e38f8 (diff)
downloadsystem_core-9aec926f866f54a311bd898b5f51188f9890a357.tar.gz
system_core-9aec926f866f54a311bd898b5f51188f9890a357.tar.bz2
system_core-9aec926f866f54a311bd898b5f51188f9890a357.zip
libmetricslogger: Refactor Tron metrics histogram logging out of
bootstat. To be shared with other native components that want to log histograms. Bug: 34456830 Test: libmetricslogger_test Change-Id: I94a1a91c6d33e443d66bc480158dc2470d6c9031
Diffstat (limited to 'bootstat')
-rw-r--r--bootstat/Android.bp6
-rw-r--r--bootstat/boot_event_record_store.cpp1
-rw-r--r--bootstat/bootstat.cpp16
-rw-r--r--bootstat/histogram_logger.cpp32
-rw-r--r--bootstat/histogram_logger.h26
5 files changed, 9 insertions, 72 deletions
diff --git a/bootstat/Android.bp b/bootstat/Android.bp
index d98a9d7dd..f744ad128 100644
--- a/bootstat/Android.bp
+++ b/bootstat/Android.bp
@@ -16,7 +16,6 @@
bootstat_lib_src_files = [
"boot_event_record_store.cpp",
- "histogram_logger.cpp",
"uptime_parser.cpp",
]
@@ -27,15 +26,12 @@ cc_defaults {
"-Wall",
"-Wextra",
"-Werror",
-
- // 524291 corresponds to sysui_histogram, from
- // frameworks/base/core/java/com/android/internal/logging/EventLogTags.logtags
- "-DHISTOGRAM_LOG_TAG=524291",
],
shared_libs: [
"libbase",
"libcutils",
"liblog",
+ "libmetricslogger",
],
whole_static_libs: ["libgtest_prod"],
// Clang is required because of C++14
diff --git a/bootstat/boot_event_record_store.cpp b/bootstat/boot_event_record_store.cpp
index f902af337..26485942d 100644
--- a/bootstat/boot_event_record_store.cpp
+++ b/bootstat/boot_event_record_store.cpp
@@ -26,7 +26,6 @@
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/parseint.h>
-#include "histogram_logger.h"
#include "uptime_parser.h"
namespace {
diff --git a/bootstat/bootstat.cpp b/bootstat/bootstat.cpp
index a626704cc..595239ca8 100644
--- a/bootstat/bootstat.cpp
+++ b/bootstat/bootstat.cpp
@@ -33,9 +33,9 @@
#include <android-base/logging.h>
#include <android-base/parseint.h>
#include <cutils/properties.h>
+#include <metricslogger/metrics_logger.h>
#include "boot_event_record_store.h"
-#include "histogram_logger.h"
#include "uptime_parser.h"
namespace {
@@ -47,7 +47,7 @@ void LogBootEvents() {
auto events = boot_event_store.GetAllBootEvents();
for (auto i = events.cbegin(); i != events.cend(); ++i) {
- bootstat::LogHistogram(i->first, i->second);
+ android::metricslogger::LogHistogram(i->first, i->second);
}
}
@@ -292,18 +292,18 @@ void RecordFactoryReset() {
if (current_time_utc < 0) {
// UMA does not display negative values in buckets, so convert to positive.
- bootstat::LogHistogram(
+ android::metricslogger::LogHistogram(
"factory_reset_current_time_failure", std::abs(current_time_utc));
- // Logging via BootEventRecordStore to see if using bootstat::LogHistogram
+ // Logging via BootEventRecordStore to see if using android::metricslogger::LogHistogram
// is losing records somehow.
boot_event_store.AddBootEventWithValue(
"factory_reset_current_time_failure", std::abs(current_time_utc));
return;
} else {
- bootstat::LogHistogram("factory_reset_current_time", current_time_utc);
+ android::metricslogger::LogHistogram("factory_reset_current_time", current_time_utc);
- // Logging via BootEventRecordStore to see if using bootstat::LogHistogram
+ // Logging via BootEventRecordStore to see if using android::metricslogger::LogHistogram
// is losing records somehow.
boot_event_store.AddBootEventWithValue(
"factory_reset_current_time", current_time_utc);
@@ -322,9 +322,9 @@ void RecordFactoryReset() {
// Calculate and record the difference in time between now and the
// factory_reset time.
time_t factory_reset_utc = record.second;
- bootstat::LogHistogram("factory_reset_record_value", factory_reset_utc);
+ android::metricslogger::LogHistogram("factory_reset_record_value", factory_reset_utc);
- // Logging via BootEventRecordStore to see if using bootstat::LogHistogram
+ // Logging via BootEventRecordStore to see if using android::metricslogger::LogHistogram
// is losing records somehow.
boot_event_store.AddBootEventWithValue(
"factory_reset_record_value", factory_reset_utc);
diff --git a/bootstat/histogram_logger.cpp b/bootstat/histogram_logger.cpp
deleted file mode 100644
index 73f32951f..000000000
--- a/bootstat/histogram_logger.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2016 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 "histogram_logger.h"
-
-#include <cstdlib>
-
-#include <android-base/logging.h>
-#include <log/log_event_list.h>
-
-namespace bootstat {
-
-void LogHistogram(const std::string& event, int32_t data) {
- LOG(INFO) << "Logging histogram: " << event << " " << data;
- android_log_event_list log(HISTOGRAM_LOG_TAG);
- log << event << data << LOG_ID_EVENTS;
-}
-
-} // namespace bootstat
diff --git a/bootstat/histogram_logger.h b/bootstat/histogram_logger.h
deleted file mode 100644
index 60c7776a6..000000000
--- a/bootstat/histogram_logger.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2016 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 <cstdint>
-#include <string>
-
-namespace bootstat {
-
-// Builds an EventLog buffer named |event| containing |data| and writes
-// the log into the Tron histogram logs.
-void LogHistogram(const std::string& event, int32_t data);
-
-} // namespace bootstat \ No newline at end of file