summaryrefslogtreecommitdiffstats
path: root/chrome/common/metrics_helpers.cc
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-01 23:40:51 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-01 23:40:51 +0000
commit022001851f2f6be890f9b44c49fa45ea38fa80b2 (patch)
tree9ea0cc9ac76b7002421110a5dee0ae60082740aa /chrome/common/metrics_helpers.cc
parentada794814ca34a4761b21b1c2562cc75de22ff52 (diff)
downloadchromium_src-022001851f2f6be890f9b44c49fa45ea38fa80b2.zip
chromium_src-022001851f2f6be890f9b44c49fa45ea38fa80b2.tar.gz
chromium_src-022001851f2f6be890f9b44c49fa45ea38fa80b2.tar.bz2
Try to detect internal corruption of histogram instances.
Corruptions can include changes in bucket boundaries, large changes in sample counts (in a bucket), etc. We now detect problems, and don't forward the corrupt data any further. This means it won't exit the renderer and go to the browser if corrupt, and it won't exit the browser and be sent up via UMA if corrupt. IF the would-be corruption is caused by a race to snapshot the data, then a later snapshot should get the clean copy, and all data (across the precluded period) will be sent onward. BUG=61281 r=mbelshe Review URL: http://codereview.chromium.org/4174002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64687 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/metrics_helpers.cc')
-rw-r--r--chrome/common/metrics_helpers.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/chrome/common/metrics_helpers.cc b/chrome/common/metrics_helpers.cc
index 6dd0a42..e25355c 100644
--- a/chrome/common/metrics_helpers.cc
+++ b/chrome/common/metrics_helpers.cc
@@ -484,9 +484,25 @@ void MetricsServiceBase::RecordHistogram(const Histogram& histogram) {
// Get up-to-date snapshot of sample stats.
Histogram::SampleSet snapshot;
histogram.SnapshotSample(&snapshot);
-
const std::string& histogram_name = histogram.histogram_name();
+ int corruption = histogram.FindCorruption(snapshot);
+ if (corruption) {
+ NOTREACHED();
+ // Don't send corrupt data to metrics survices.
+ UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowser",
+ corruption, Histogram::NEVER_EXCEEDED_VALUE);
+ typedef std::map<std::string, int> ProblemMap;
+ static ProblemMap* inconsistencies = new ProblemMap;
+ int old_corruption = (*inconsistencies)[histogram_name];
+ if (old_corruption == (corruption | old_corruption))
+ return; // We've already seen this corruption for this histogram.
+ (*inconsistencies)[histogram_name] |= corruption;
+ UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowserUnique",
+ corruption, Histogram::NEVER_EXCEEDED_VALUE);
+ return;
+ }
+
// Find the already sent stats, or create an empty set.
LoggedSampleMap::iterator it = logged_samples_.find(histogram_name);
Histogram::SampleSet* already_logged;