metrics_daemon: restore correct meaning of Logging.DailyUse.
Maintain separate persistent values for DailyActiveUse and
CumulativeActiveUse. The latter is used to compute crash rates
relative to active use.
BUG=chromium:364746
TEST=manual
Change-Id: I4d0485016eb49b30a77169ba1cedc1ffbff8810e
Reviewed-on: https://chromium-review.googlesource.com/195698
Reviewed-by: Daniel Erat <derat@chromium.org>
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
diff --git a/metrics/metrics_daemon.cc b/metrics/metrics_daemon.cc
index d1eb25e..97c099c 100644
--- a/metrics/metrics_daemon.cc
+++ b/metrics/metrics_daemon.cc
@@ -170,6 +170,7 @@
if (version_cycle_->Get() != version) {
version_cycle_->Set(version);
kernel_crashes_version_count_->Set(0);
+ version_cumulative_active_use_->Set(0);
version_cumulative_cpu_use_->Set(0);
}
@@ -206,8 +207,10 @@
// Sysconf cannot fail, so no sanity checks are needed.
ticks_per_second_ = sysconf(_SC_CLK_TCK);
- daily_use_.reset(
+ daily_active_use_.reset(
new PersistentInteger("Logging.DailyUseTime"));
+ version_cumulative_active_use_.reset(
+ new PersistentInteger("Logging.CumulativeDailyUseTime"));
version_cumulative_cpu_use_.reset(
new PersistentInteger("Logging.CumulativeCpuTime"));
@@ -931,8 +934,7 @@
metrics_lib_->SendToUMA(name, sample, min, max, nbuckets);
}
-void MetricsDaemon::SendKernelCrashesCumulativeCountStats(
- int64 active_use_seconds) {
+void MetricsDaemon::SendKernelCrashesCumulativeCountStats() {
// Report the number of crashes for this OS version, but don't clear the
// counter. It is cleared elsewhere on version change.
int64 crashes_count = kernel_crashes_version_count_->Get();
@@ -961,7 +963,13 @@
100);
}
+ int64 active_use_seconds = version_cumulative_active_use_->Get();
if (active_use_seconds > 0) {
+ SendSample(version_cumulative_active_use_->Name(),
+ active_use_seconds / 1000, // stat is in seconds
+ 1, // device may be used very little...
+ 8 * 1000 * 1000, // ... or a lot (about 90 days)
+ 100);
// Same as above, but per year of active time.
SendSample("Logging.KernelCrashesPerActiveYear",
crashes_count * kSecondsPerDay * 365 / active_use_seconds,
@@ -971,6 +979,15 @@
}
}
+void MetricsDaemon::SendDailyUseSample(
+ const scoped_ptr<PersistentInteger>& use) {
+ SendSample(use->Name(),
+ use->GetAndClear(),
+ 1, // value of first bucket
+ kSecondsPerDay, // value of last bucket
+ 50); // number of buckets
+}
+
void MetricsDaemon::SendCrashIntervalSample(
const scoped_ptr<PersistentInteger>& interval) {
SendSample(interval->Name(),
@@ -1000,7 +1017,8 @@
void MetricsDaemon::UpdateStats(TimeTicks now_ticks,
Time now_wall_time) {
const int elapsed_seconds = (now_ticks - last_update_stats_time_).InSeconds();
- daily_use_->Add(elapsed_seconds);
+ daily_active_use_->Add(elapsed_seconds);
+ version_cumulative_active_use_->Add(elapsed_seconds);
user_crash_interval_->Add(elapsed_seconds);
kernel_crash_interval_->Add(elapsed_seconds);
version_cumulative_cpu_use_->Add(GetIncrementalCpuUse().InMilliseconds());
@@ -1012,11 +1030,13 @@
if (daily_cycle_->Get() != day) {
daily_cycle_->Set(day);
+ SendDailyUseSample(daily_active_use_);
+ SendDailyUseSample(version_cumulative_active_use_);
SendCrashFrequencySample(any_crashes_daily_count_);
SendCrashFrequencySample(user_crashes_daily_count_);
SendCrashFrequencySample(kernel_crashes_daily_count_);
SendCrashFrequencySample(unclean_shutdowns_daily_count_);
- SendKernelCrashesCumulativeCountStats(daily_use_->Get());
+ SendKernelCrashesCumulativeCountStats();
}
if (weekly_cycle_->Get() != week) {