summaryrefslogtreecommitdiffstats
path: root/metricsd/metrics_library.cc
diff options
context:
space:
mode:
authorBertrand SIMONNET <bsimonnet@google.com>2015-12-02 17:19:40 -0800
committerBertrand SIMONNET <bsimonnet@google.com>2015-12-04 13:14:58 -0800
commitb13527d14eacf6fbed4e5f7be8245755279c203e (patch)
tree219dfdb5e3740c5c8b31ccb46fa8d57a83cc696a /metricsd/metrics_library.cc
parentf2297eeb1f6ceb7242f26d2e365031c317e42040 (diff)
downloadcore-b13527d14eacf6fbed4e5f7be8245755279c203e.tar.gz
core-b13527d14eacf6fbed4e5f7be8245755279c203e.tar.bz2
core-b13527d14eacf6fbed4e5f7be8245755279c203e.zip
metricsd: Allows introspecting the metrics.
This CL adds a dump command to metrics_client that will dump the histograms, aggregated by metricsd since it started, in a human readable format. This is useful for developers to ensure that their code uses libmetrics correctly and the reported values are correct. Sample output (redacted to fit the commit message): $ metrics_client -d Histogram: hello recorded 5 samples, average = 54.8 (flags = 0x1) 0 ... 9 --------O (1 = 20.0%) {0.0%} 16 O (0 = 0.0%) {20.0%} 29 --------O (1 = 20.0%) {20.0%} 54 ------------------------O (3 = 60.0%) {40.0%} 100 O (0 = 0.0%) {100.0%} $ Bug: 25817310 Test: * Send a histogram with metrics_client. * `metrics_client -d` shows it. Change-Id: Id186dc5463403ca9181ee9eef8f46b5e809b8714
Diffstat (limited to 'metricsd/metrics_library.cc')
-rw-r--r--metricsd/metrics_library.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/metricsd/metrics_library.cc b/metricsd/metrics_library.cc
index 263c310dc..d211ab448 100644
--- a/metricsd/metrics_library.cc
+++ b/metricsd/metrics_library.cc
@@ -213,3 +213,14 @@ bool MetricsLibrary::SendCrosEventToUMA(const std::string& event) {
}
return false;
}
+
+bool MetricsLibrary::GetHistogramsDump(std::string* dump) {
+ android::String16 temp_dump;
+ if (!CheckService() ||
+ !metricsd_proxy_->getHistogramsDump(&temp_dump).isOk()) {
+ return false;
+ }
+
+ *dump = android::String8(temp_dump).string();
+ return true;
+}