port metrics_logger to v2 format
Bug: 34450377
Test: manual, needs to be a cross-language test
Change-Id: Ib89a48f2c52428deff863b0c28f3c10e7333c8a2
diff --git a/libmetricslogger/Android.bp b/libmetricslogger/Android.bp
index 75eab66..da8afe1 100644
--- a/libmetricslogger/Android.bp
+++ b/libmetricslogger/Android.bp
@@ -22,7 +22,7 @@
// 524291 corresponds to sysui_histogram, from
// frameworks/base/core/java/com/android/internal/logging/EventLogTags.logtags
- "-DHISTOGRAM_LOG_TAG=524291",
+ "-DHISTOGRAM_LOG_TAG=524292",
],
}
diff --git a/libmetricslogger/include/metricslogger/metrics_logger.h b/libmetricslogger/include/metricslogger/metrics_logger.h
index d30e56c..26aa189 100644
--- a/libmetricslogger/include/metricslogger/metrics_logger.h
+++ b/libmetricslogger/include/metricslogger/metrics_logger.h
@@ -24,5 +24,14 @@
// buffer.
void LogHistogram(const std::string& event, int32_t data);
+// TODO: replace these with the metric_logger.proto definitions
+enum {
+ LOGBUILDER_CATEGORY = 757,
+ LOGBUILDER_NAME = 799,
+ LOGBUILDER_BUCKET = 801,
+ LOGBUILDER_VALUE = 802,
+ LOGBUILDER_HISTOGRAM = 804,
+};
+
} // namespace metricslogger
} // namespace android
diff --git a/libmetricslogger/metrics_logger.cpp b/libmetricslogger/metrics_logger.cpp
index f8e0174..0d08f5c 100644
--- a/libmetricslogger/metrics_logger.cpp
+++ b/libmetricslogger/metrics_logger.cpp
@@ -23,9 +23,14 @@
namespace android {
namespace metricslogger {
+// Mirror com.android.internal.logging.MetricsLogger#histogram().
void LogHistogram(const std::string& event, int32_t data) {
android_log_event_list log(HISTOGRAM_LOG_TAG);
- log << event << data << LOG_ID_EVENTS;
+ log << LOGBUILDER_CATEGORY << LOGBUILDER_HISTOGRAM
+ << LOGBUILDER_NAME << event
+ << LOGBUILDER_BUCKET << data
+ << LOGBUILDER_VALUE << 1
+ << LOG_ID_EVENTS;
}
} // namespace metricslogger