metrics_daemon: report cumulative daily use.

This had been lost in the previous changes.  Also, the meaning
of DailyUse changes: it is now cumulative daily use.  But we should
revise these stats so I think it's OK for now.

BUG=chromium:339588
TEST=unit tests

Change-Id: I4894fef0ffb237633abcf949c01dd7ea5f5e5d6e
Reviewed-on: https://chromium-review.googlesource.com/195005
Reviewed-by: Daniel Erat <derat@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
This commit is contained in:
Luigi Semenzato 2014-04-15 15:15:02 -07:00 committed by chrome-internal-fetch
parent a5f4fe6b98
commit 5ef2e39119
3 changed files with 14 additions and 15 deletions

View File

@ -421,6 +421,7 @@ void MetricsDaemon::ReportStats(int64 active_use_seconds, Time now) {
daily_cycle_->Set(day);
// Daily stats.
ReportDailyUse(active_use_seconds);
SendCrashFrequencySample(any_crashes_daily_count_);
SendCrashFrequencySample(user_crashes_daily_count_);
SendCrashFrequencySample(kernel_crashes_daily_count_);
@ -1125,18 +1126,16 @@ bool MetricsDaemon::ProcessMemuse(const string& meminfo_raw) {
return true;
}
// static
void MetricsDaemon::ReportDailyUse(void* handle, int count) {
if (count <= 0)
void MetricsDaemon::ReportDailyUse(int use_seconds) {
if (use_seconds <= 0)
return;
MetricsDaemon* daemon = static_cast<MetricsDaemon*>(handle);
int minutes = (count + kSecondsPerMinute / 2) / kSecondsPerMinute;
daemon->SendSample("Logging.DailyUseTime",
minutes,
1,
kMinutesPerDay,
50);
int minutes = (use_seconds + kSecondsPerMinute / 2) / kSecondsPerMinute;
SendSample("Logging.DailyUseTime",
minutes,
1,
kMinutesPerDay * 30 * 2, // cumulative---two months worth
50);
}
void MetricsDaemon::SendSample(const string& name, int sample,

View File

@ -231,7 +231,7 @@ class MetricsDaemon {
void UnscheduleUseMonitor();
// Report daily use through UMA.
static void ReportDailyUse(void* handle, int count);
void ReportDailyUse(int use_seconds);
// Sends a regular (exponential) histogram sample to Chrome for
// transport to UMA. See MetricsLibrary::SendToUMA in

View File

@ -230,14 +230,14 @@ TEST_F(MetricsDaemonTest, CheckSystemCrash) {
TEST_F(MetricsDaemonTest, ReportDailyUse) {
ExpectDailyUseTimeSample(/* sample */ 2);
MetricsDaemon::ReportDailyUse(&daemon_, /* count */ 90);
daemon_.ReportDailyUse(/* count */ 90);
ExpectDailyUseTimeSample(/* sample */ 1);
MetricsDaemon::ReportDailyUse(&daemon_, /* count */ 89);
daemon_.ReportDailyUse(/* count */ 89);
// There should be no metrics generated for the calls below.
MetricsDaemon::ReportDailyUse(&daemon_, /* count */ 0);
MetricsDaemon::ReportDailyUse(&daemon_, /* count */ -5);
daemon_.ReportDailyUse(/* count */ 0);
daemon_.ReportDailyUse(/* count */ -5);
}
TEST_F(MetricsDaemonTest, LookupPowerState) {