metrics: add per-version cumulative counters
This adds counters that accumulate some measurement across an OS version;
they are reset at version updates, but reported more frequently (for instance,
daily).
Such counts could be obtained by pseudonymous dremel queries, but this is
more convenient.
The code replaces the "tag" datum in the counters with two tags: a
"report tag" and a "reset tag". When the report
tag changes, the count is reported but not reset. When the reset tag
changes, the count is both reported and reset.
This also adds one usage of the new counter which tracks the total
number of kernel crashes since the most recent OS version update.
The state machine in counter.cc changes a bit because it's no longer
true that a counter is reset after reporting it. That logic is
still rather confusing, and could use a rewrite.
BUG=chromium:339588
TEST=ran on target under various situations
BRANCH=none
Change-Id: I5f83731e1a3d6e055b6d0f89111c9ffc60ccfcb9
Reviewed-on: https://chromium-review.googlesource.com/185081
Reviewed-by: Daniel Erat <derat@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
diff --git a/metrics/metrics_daemon.h b/metrics/metrics_daemon.h
index 6ceb136..6d8f81b 100644
--- a/metrics/metrics_daemon.h
+++ b/metrics/metrics_daemon.h
@@ -18,6 +18,7 @@
namespace chromeos_metrics {
class FrequencyCounter;
+class VersionCounter;
class TaggedCounter;
class TaggedCounterReporter;
}
@@ -133,20 +134,25 @@
// Metric parameters.
static const char kMetricAnyCrashesDailyName[];
static const char kMetricAnyCrashesWeeklyName[];
- static const char kMetricCrashFrequencyBuckets;
- static const char kMetricCrashFrequencyMax;
- static const char kMetricCrashFrequencyMin;
+ static const int kMetricCrashFrequencyBuckets;
+ static const int kMetricCrashFrequencyMax;
+ static const int kMetricCrashFrequencyMin;
static const int kMetricCrashIntervalBuckets;
static const int kMetricCrashIntervalMax;
static const int kMetricCrashIntervalMin;
+ static const int kMetricCumulativeCrashCountBuckets;
+ static const int kMetricCumulativeCrashCountMax;
+ static const int kMetricCumulativeCrashCountMin;
static const int kMetricDailyUseTimeBuckets;
static const int kMetricDailyUseTimeMax;
static const int kMetricDailyUseTimeMin;
static const char kMetricDailyUseTimeName[];
static const char kMetricKernelCrashesDailyName[];
static const char kMetricKernelCrashesWeeklyName[];
+ static const char kMetricKernelCrashesVersionName[];
static const char kMetricKernelCrashIntervalName[];
static const char kMetricsPath[];
+ static const char kLsbReleasePath[];
static const char kMetricUncleanShutdownIntervalName[];
static const char kMetricUncleanShutdownsDailyName[];
static const char kMetricUncleanShutdownsWeeklyName[];
@@ -194,6 +200,9 @@
// Configures the given frequency counter reporter.
void ConfigureCrashFrequencyReporter(const char* histogram_name);
+ // Configures the given version counter reporter.
+ void ConfigureCrashVersionReporter(const char* histogram_name);
+
// Returns file path to persistent file for generating given histogram.
base::FilePath GetHistogramPath(const char* histogram_name);
@@ -271,7 +280,7 @@
void UnscheduleUseMonitor();
// Report daily use through UMA.
- static void ReportDailyUse(void* handle, int tag, int count);
+ static void ReportDailyUse(void* handle, int count);
// Sends a regular (exponential) histogram sample to Chrome for
// transport to UMA. See MetricsLibrary::SendToUMA in
@@ -352,6 +361,10 @@
// Reads an integer CPU frequency value from sysfs.
bool ReadFreqToInt(const std::string& sysfs_file_name, int* value);
+ // Reads the current OS version from /etc/lsb-release and hashes it
+ // to a unsigned 32-bit int.
+ uint32 GetOsVersionHash();
+
// Test mode.
bool testing_;
@@ -394,6 +407,10 @@
// Map of all frequency counters, to simplify flushing them.
FrequencyCounters frequency_counters_;
+ // This contains a cumulative number of kernel crashes since the latest
+ // version update.
+ chromeos_metrics::VersionCounter* kernel_crash_version_counter_;
+
// Sleep period until the next daily usage aggregation performed by
// the daily use monitor (see ScheduleUseMonitor).
int usemon_interval_;