diff options
| author | rajendrant <rajendrant@chromium.org> | 2016-01-15 17:09:44 -0800 |
|---|---|---|
| committer | Commit bot <commit-bot@chromium.org> | 2016-01-16 01:10:35 +0000 |
| commit | b582452daa579977cb9200d398d53b4de8cc4ae5 (patch) | |
| tree | 7a166166685b6681fc473b2cef66f60a95d0547e | |
| parent | 88105b63e6a1f3f9610d7fc21ae1979201d32562 (diff) | |
| download | chromium_src-b582452daa579977cb9200d398d53b4de8cc4ae5.zip chromium_src-b582452daa579977cb9200d398d53b4de8cc4ae5.tar.gz chromium_src-b582452daa579977cb9200d398d53b4de8cc4ae5.tar.bz2 | |
Add histograms for data usage
The following UMA are added:
DataUsage.MatchingRulesCount.Valid
DataUsage.MatchingRulesCount.Invalid
- The number of valid and invalid matching rules fetched.
DataUsage.Perf.URLRegexMatchDuration
- Time taken for a regular expression to process an URL.
DataUsage.Perf.ReportSubmissionDuration
- Time taken for submitting the data use reports.
DataUsage.Perf.MatchingRuleFetchDuration
- Time taken for fetching the matching rules.
BUG=574880
Review URL: https://codereview.chromium.org/1582043002
Cr-Commit-Position: refs/heads/master@{#369900}
7 files changed, 199 insertions, 37 deletions
diff --git a/chrome/browser/android/data_usage/data_use_matcher.cc b/chrome/browser/android/data_usage/data_use_matcher.cc index 8959c64..21e435c 100644 --- a/chrome/browser/android/data_usage/data_use_matcher.cc +++ b/chrome/browser/android/data_usage/data_use_matcher.cc @@ -10,9 +10,11 @@ #include <utility> #include "base/memory/weak_ptr.h" +#include "base/metrics/histogram_macros.h" #include "base/strings/string_number_conversions.h" #include "base/time/default_tick_clock.h" #include "base/time/tick_clock.h" +#include "base/time/time.h" #include "chrome/browser/android/data_usage/external_data_use_observer.h" #include "third_party/re2/src/re2/re2.h" #include "url/gurl.h" @@ -46,6 +48,7 @@ void DataUseMatcher::RegisterURLRegexes( DCHECK_EQ(app_package_names.size(), labels.size()); base::hash_set<std::string> removed_matching_rule_labels; + uint32_t invalid_rules = 0; for (const auto& matching_rule : matching_rules_) removed_matching_rule_labels.insert(matching_rule->label()); @@ -61,11 +64,15 @@ void DataUseMatcher::RegisterURLRegexes( const base::TimeTicks now_ticks = tick_clock_->NowTicks(); ParsePackageField(app_package_names.at(i), &app_package_name, &expiration); - if (url_regex.empty() && app_package_name.empty()) + if (url_regex.empty() && app_package_name.empty()) { + invalid_rules++; continue; + } scoped_ptr<re2::RE2> pattern(new re2::RE2(url_regex, options)); - if (!pattern->ok()) + if (!pattern->ok()) { + invalid_rules++; continue; + } if (expiration <= now_ticks) continue; // skip expired matching rules. @@ -80,6 +87,11 @@ void DataUseMatcher::RegisterURLRegexes( if (data_use_tab_model_) data_use_tab_model_->OnTrackingLabelRemoved(label); } + UMA_HISTOGRAM_COUNTS_100("DataUsage.MatchingRulesCount.Valid", + matching_rules_.size()); + UMA_HISTOGRAM_COUNTS_100("DataUsage.MatchingRulesCount.Invalid", + invalid_rules); + DCHECK(io_task_runner_); // Notify |external_data_use_observer_| if it should register as a data use @@ -101,7 +113,11 @@ bool DataUseMatcher::MatchesURL(const GURL& url, std::string* label) const { for (const auto& matching_rule : matching_rules_) { if (matching_rule->expiration() <= now_ticks) continue; // skip expired matching rules. - if (re2::RE2::FullMatch(url.spec(), *(matching_rule->pattern()))) { + base::TimeTicks begin = base::TimeTicks::Now(); + bool match = re2::RE2::FullMatch(url.spec(), *(matching_rule->pattern())); + UMA_HISTOGRAM_TIMES("DataUsage.Perf.URLRegexMatchDuration", + base::TimeTicks::Now() - begin); + if (match) { *label = matching_rule->label(); return true; } diff --git a/chrome/browser/android/data_usage/data_use_matcher_unittest.cc b/chrome/browser/android/data_usage/data_use_matcher_unittest.cc index 759a23c..318e519 100644 --- a/chrome/browser/android/data_usage/data_use_matcher_unittest.cc +++ b/chrome/browser/android/data_usage/data_use_matcher_unittest.cc @@ -13,6 +13,7 @@ #include "base/macros.h" #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" +#include "base/test/histogram_tester.h" #include "base/time/tick_clock.h" #include "base/time/time.h" #include "chrome/browser/android/data_usage/external_data_use_observer.h" @@ -23,6 +24,13 @@ namespace { +const char kUMAMatchingRulesCountValidHistogram[] = + "DataUsage.MatchingRulesCount.Valid"; +const char kUMAMatchingRulesCountInvalidHistogram[] = + "DataUsage.MatchingRulesCount.Invalid"; +const char kUMAURLRegexMatchDurationHistogram[] = + "DataUsage.Perf.URLRegexMatchDuration"; + const char kRegexFoo[] = "http://foo.com/"; const char kLabelFoo[] = "label_foo"; const char kAppFoo[] = "com.example.foo"; @@ -94,39 +102,52 @@ TEST_F(DataUseMatcherTest, SingleRegex) { std::string url; std::string regex; bool expect_match; + int expect_count_valid_rules; + int expect_count_url_match_duration_samples; } tests[] = { - {"http://www.google.com", "http://www.google.com/", true}, - {"http://www.Google.com", "http://www.google.com/", true}, - {"http://www.googleacom", "http://www.google.com/", true}, - {"http://www.googleaacom", "http://www.google.com/", false}, - {"http://www.google.com", "https://www.google.com/", false}, + {"http://www.google.com", "http://www.google.com/", true, 1, 1}, + {"http://www.Google.com", "http://www.google.com/", true, 1, 1}, + {"http://www.googleacom", "http://www.google.com/", true, 1, 1}, + {"http://www.googleaacom", "http://www.google.com/", false, 1, 1}, + {"http://www.google.com", "https://www.google.com/", false, 1, 1}, {"http://www.google.com", "{http|https}://www[.]google[.]com/search.*", - false}, + false, 1, 1}, {"https://www.google.com/search=test", - "https://www[.]google[.]com/search.*", true}, + "https://www[.]google[.]com/search.*", true, 1, 1}, {"https://www.googleacom/search=test", - "https://www[.]google[.]com/search.*", false}, + "https://www[.]google[.]com/search.*", false, 1, 1}, {"https://www.google.com/Search=test", - "https://www[.]google[.]com/search.*", true}, - {"www.google.com", "http://www.google.com", false}, - {"www.google.com:80", "http://www.google.com", false}, - {"http://www.google.com:80", "http://www.google.com", false}, - {"http://www.google.com:80/", "http://www.google.com/", true}, - {"", "http://www.google.com", false}, - {"", "", false}, - {"https://www.google.com", "http://www.google.com", false}, + "https://www[.]google[.]com/search.*", true, 1, 1}, + {"www.google.com", "http://www.google.com", false, 1, 0}, + {"www.google.com:80", "http://www.google.com", false, 1, 1}, + {"http://www.google.com:80", "http://www.google.com", false, 1, 1}, + {"http://www.google.com:80/", "http://www.google.com/", true, 1, 1}, + {"", "http://www.google.com", false, 1, 0}, + {"", "", false, 0, 0}, + {"https://www.google.com", "http://www.google.com", false, 1, 1}, + {"https://www.google.com", "[", false, 0}, + {"https://www.google.com", "]", false, 1, 1}, }; for (size_t i = 0; i < arraysize(tests); ++i) { + base::HistogramTester histogram_tester; std::string label(""); RegisterURLRegexes( // App package name not specified in the matching rule. std::vector<std::string>(1, std::string()), std::vector<std::string>(1, tests[i].regex), std::vector<std::string>(1, "label")); + histogram_tester.ExpectUniqueSample(kUMAMatchingRulesCountValidHistogram, + tests[i].expect_count_valid_rules, 1); + histogram_tester.ExpectUniqueSample(kUMAMatchingRulesCountInvalidHistogram, + 1 - tests[i].expect_count_valid_rules, + 1); EXPECT_EQ(tests[i].expect_match, data_use_matcher()->MatchesURL(GURL(tests[i].url), &label)) << i; + histogram_tester.ExpectTotalCount( + kUMAURLRegexMatchDurationHistogram, + tests[i].expect_count_url_match_duration_samples); // Verify label matches the expected label. std::string expected_label = ""; @@ -151,37 +172,40 @@ TEST_F(DataUseMatcherTest, TwoRegex) { std::string regex1; std::string regex2; bool expect_match; + int expect_count_valid_rules; + int expect_count_url_match_duration_samples; } tests[] = { {"http://www.google.com", "http://www.google.com/", - "https://www.google.com/", true}, + "https://www.google.com/", true, 1, 1}, {"http://www.googleacom", "http://www.google.com/", - "http://www.google.com/", true}, + "http://www.google.com/", true, 1, 1}, {"https://www.google.com", "http://www.google.com/", - "https://www.google.com/", true}, + "https://www.google.com/", true, 1, 1}, {"https://www.googleacom", "http://www.google.com/", - "https://www.google.com/", true}, + "https://www.google.com/", true, 1, 1}, {"http://www.google.com", "{http|https}://www[.]google[.]com/search.*", - "", false}, + "", false, 1, 1}, {"http://www.google.com/search=test", "http://www[.]google[.]com/search.*", - "https://www[.]google[.]com/search.*", true}, + "https://www[.]google[.]com/search.*", true, 1, 1}, {"https://www.google.com/search=test", "http://www[.]google[.]com/search.*", - "https://www[.]google[.]com/search.*", true}, + "https://www[.]google[.]com/search.*", true, 1, 1}, {"http://google.com/search=test", "http://www[.]google[.]com/search.*", - "https://www[.]google[.]com/search.*", false}, + "https://www[.]google[.]com/search.*", false, 1, 1}, {"https://www.googleacom/search=test", "", - "https://www[.]google[.]com/search.*", false}, + "https://www[.]google[.]com/search.*", false, 1, 1}, {"https://www.google.com/Search=test", "", - "https://www[.]google[.]com/search.*", true}, - {"www.google.com", "http://www.google.com", "", false}, - {"www.google.com:80", "http://www.google.com", "", false}, - {"http://www.google.com:80", "http://www.google.com", "", false}, - {"", "http://www.google.com", "", false}, - {"https://www.google.com", "http://www.google.com", "", false}, + "https://www[.]google[.]com/search.*", true, 1, 1}, + {"www.google.com", "http://www.google.com", "", false, 1, 0}, + {"www.google.com:80", "http://www.google.com", "", false, 1, 1}, + {"http://www.google.com:80", "http://www.google.com", "", false, 1, 1}, + {"", "http://www.google.com", "", false, 1, 0}, + {"https://www.google.com", "http://www.google.com", "", false, 1, 1}, }; for (size_t i = 0; i < arraysize(tests); ++i) { + base::HistogramTester histogram_tester; std::string got_label(""); std::vector<std::string> url_regexes; url_regexes.push_back(tests[i].regex1 + "|" + tests[i].regex2); @@ -189,9 +213,20 @@ TEST_F(DataUseMatcherTest, TwoRegex) { RegisterURLRegexes( std::vector<std::string>(url_regexes.size(), "com.example.helloworld"), url_regexes, std::vector<std::string>(url_regexes.size(), label)); + histogram_tester.ExpectTotalCount(kUMAMatchingRulesCountValidHistogram, 1); + histogram_tester.ExpectTotalCount(kUMAMatchingRulesCountInvalidHistogram, + 1); + histogram_tester.ExpectUniqueSample(kUMAMatchingRulesCountValidHistogram, + tests[i].expect_count_valid_rules, 1); + histogram_tester.ExpectUniqueSample(kUMAMatchingRulesCountInvalidHistogram, + 1 - tests[i].expect_count_valid_rules, + 1); EXPECT_EQ(tests[i].expect_match, data_use_matcher()->MatchesURL(GURL(tests[i].url), &got_label)) << i; + histogram_tester.ExpectTotalCount( + kUMAURLRegexMatchDurationHistogram, + tests[i].expect_count_url_match_duration_samples); const std::string expected_label = tests[i].expect_match ? label : std::string(); EXPECT_EQ(expected_label, got_label); @@ -204,6 +239,7 @@ TEST_F(DataUseMatcherTest, TwoRegex) { } TEST_F(DataUseMatcherTest, MultipleRegex) { + base::HistogramTester histogram_tester; std::vector<std::string> url_regexes; url_regexes.push_back( "https?://www[.]google[.]com/#q=.*|https?://www[.]google[.]com[.]ph/" @@ -211,6 +247,10 @@ TEST_F(DataUseMatcherTest, MultipleRegex) { RegisterURLRegexes( std::vector<std::string>(url_regexes.size(), std::string()), url_regexes, std::vector<std::string>(url_regexes.size(), "label")); + histogram_tester.ExpectUniqueSample(kUMAMatchingRulesCountValidHistogram, 1, + 1); + histogram_tester.ExpectUniqueSample(kUMAMatchingRulesCountInvalidHistogram, 0, + 1); const struct { std::string url; @@ -285,6 +325,7 @@ TEST_F(DataUseMatcherTest, ChangeRegex) { } TEST_F(DataUseMatcherTest, MultipleAppPackageName) { + base::HistogramTester histogram_tester; std::vector<std::string> url_regexes; url_regexes.push_back( "http://www[.]foo[.]com/#q=.*|https://www[.]foo[.]com/#q=.*"); @@ -307,6 +348,10 @@ TEST_F(DataUseMatcherTest, MultipleAppPackageName) { app_package_names.push_back(kAppBaz); RegisterURLRegexes(app_package_names, url_regexes, labels); + histogram_tester.ExpectUniqueSample(kUMAMatchingRulesCountValidHistogram, 3, + 1); + histogram_tester.ExpectUniqueSample(kUMAMatchingRulesCountInvalidHistogram, 0, + 1); // Test if labels are matched properly for app package names. std::string got_label; @@ -387,6 +432,7 @@ TEST_F(DataUseMatcherTest, ParsePackageField) { // Tests if the expiration time encoded as milliseconds since epoch is parsed // correctly. TEST_F(DataUseMatcherTest, EncodeExpirationTimeInPackageName) { + base::HistogramTester histogram_tester; NowTestTickClock* tick_clock = new NowTestTickClock(); // |tick_clock| will be owned by |data_use_matcher_|. @@ -396,12 +442,16 @@ TEST_F(DataUseMatcherTest, EncodeExpirationTimeInPackageName) { url_regexes.push_back(kRegexFoo); labels.push_back(kLabelFoo); - // Set current time to to Epoch. + // Set current time to Epoch. tick_clock->set_now_ticks(base::TimeTicks::UnixEpoch()); app_package_names.push_back(base::StringPrintf("%s|%d", kAppFoo, 10000)); RegisterURLRegexes(app_package_names, url_regexes, labels); EXPECT_FALSE(IsExpired(0)); + histogram_tester.ExpectUniqueSample(kUMAMatchingRulesCountValidHistogram, 1, + 1); + histogram_tester.ExpectUniqueSample(kUMAMatchingRulesCountInvalidHistogram, 0, + 1); // Fast forward 10 seconds, and matching rule expires. tick_clock->set_now_ticks(base::TimeTicks::UnixEpoch() + base::TimeDelta::FromMilliseconds(10000 + 1)); @@ -420,6 +470,7 @@ TEST_F(DataUseMatcherTest, EncodeExpirationTimeInPackageName) { // Tests if the expiration time encoded in Java format is parsed correctly. TEST_F(DataUseMatcherTest, EncodeJavaExpirationTimeInPackageName) { + base::HistogramTester histogram_tester; std::vector<std::string> url_regexes, labels, app_package_names; url_regexes.push_back(kRegexFoo); labels.push_back(kLabelFoo); @@ -433,6 +484,10 @@ TEST_F(DataUseMatcherTest, EncodeJavaExpirationTimeInPackageName) { static_cast<long long int>(expiration_time.ToJavaTime()))); RegisterURLRegexes(app_package_names, url_regexes, labels); EXPECT_FALSE(IsExpired(0)); + histogram_tester.ExpectUniqueSample(kUMAMatchingRulesCountValidHistogram, 1, + 1); + histogram_tester.ExpectUniqueSample(kUMAMatchingRulesCountInvalidHistogram, 0, + 1); // Check if expiration duration is close to 10 seconds. EXPECT_GE(base::TimeDelta::FromMilliseconds(10001), @@ -445,6 +500,7 @@ TEST_F(DataUseMatcherTest, EncodeJavaExpirationTimeInPackageName) { // Tests that expired matching rules are ignored by MatchesURL and // MatchesAppPackageName. TEST_F(DataUseMatcherTest, MatchesIgnoresExpiredRules) { + base::HistogramTester histogram_tester; std::vector<std::string> url_regexes, labels, app_package_names; std::string got_label; NowTestTickClock* tick_clock = new NowTestTickClock(); @@ -457,6 +513,10 @@ TEST_F(DataUseMatcherTest, MatchesIgnoresExpiredRules) { labels.push_back(kLabelFoo); app_package_names.push_back(base::StringPrintf("%s|%d", kAppFoo, 10000)); RegisterURLRegexes(app_package_names, url_regexes, labels); + histogram_tester.ExpectUniqueSample(kUMAMatchingRulesCountValidHistogram, 1, + 1); + histogram_tester.ExpectUniqueSample(kUMAMatchingRulesCountInvalidHistogram, 0, + 1); tick_clock->set_now_ticks(base::TimeTicks::UnixEpoch() + base::TimeDelta::FromMilliseconds(1)); diff --git a/chrome/browser/android/data_usage/external_data_use_observer.cc b/chrome/browser/android/data_usage/external_data_use_observer.cc index 94e9e06..a1dba79 100644 --- a/chrome/browser/android/data_usage/external_data_use_observer.cc +++ b/chrome/browser/android/data_usage/external_data_use_observer.cc @@ -205,6 +205,9 @@ void ExternalDataUseObserver::OnReportDataUseDone(bool success) { RecordDataUsageReportSubmission(DATAUSAGE_REPORT_SUBMISSION_FAILED, pending_report_bytes_); } + UMA_HISTOGRAM_TIMES( + "DataUsage.Perf.ReportSubmissionDuration", + base::TimeTicks::Now() - last_data_report_submitted_ticks_); last_data_report_submitted_ticks_ = base::TimeTicks(); pending_report_bytes_ = 0; diff --git a/chrome/browser/android/data_usage/external_data_use_observer_bridge.cc b/chrome/browser/android/data_usage/external_data_use_observer_bridge.cc index 71ad96c..57cffd38 100644 --- a/chrome/browser/android/data_usage/external_data_use_observer_bridge.cc +++ b/chrome/browser/android/data_usage/external_data_use_observer_bridge.cc @@ -10,6 +10,7 @@ #include "base/android/jni_string.h" #include "base/memory/scoped_ptr.h" #include "base/metrics/field_trial.h" +#include "base/metrics/histogram_macros.h" #include "base/single_thread_task_runner.h" #include "base/time/time.h" #include "chrome/browser/android/data_usage/data_use_tab_model.h" @@ -36,7 +37,9 @@ namespace chrome { namespace android { -ExternalDataUseObserverBridge::ExternalDataUseObserverBridge() { +ExternalDataUseObserverBridge::ExternalDataUseObserverBridge() + : construct_time_(base::TimeTicks::Now()), + is_first_matching_rule_fetch_(true) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); // Detach from IO thread since rest of ExternalDataUseObserverBridge lives on @@ -96,6 +99,7 @@ void ExternalDataUseObserverBridge::FetchMatchingRulesDone( const base::android::JavaParamRef<jobjectArray>& domain_path_regex, const base::android::JavaParamRef<jobjectArray>& label) { DCHECK(thread_checker_.CalledOnValidThread()); + DCHECK(!construct_time_.is_null()); // Convert to native objects. std::vector<std::string> app_package_name_native; @@ -117,6 +121,12 @@ void ExternalDataUseObserverBridge::FetchMatchingRulesDone( if (!data_use_tab_model_) return; + if (is_first_matching_rule_fetch_) { + is_first_matching_rule_fetch_ = false; + UMA_HISTOGRAM_TIMES("DataUsage.Perf.MatchingRuleFirstFetchDuration", + base::TimeTicks::Now() - construct_time_); + } + data_use_tab_model_->RegisterURLRegexes( app_package_name_native, domain_path_regex_native, label_native); } diff --git a/chrome/browser/android/data_usage/external_data_use_observer_bridge.h b/chrome/browser/android/data_usage/external_data_use_observer_bridge.h index 2727c40..4925870 100644 --- a/chrome/browser/android/data_usage/external_data_use_observer_bridge.h +++ b/chrome/browser/android/data_usage/external_data_use_observer_bridge.h @@ -21,6 +21,7 @@ namespace base { class SingleThreadTaskRunner; class Time; +class TimeTicks; } namespace chrome { @@ -101,6 +102,12 @@ class ExternalDataUseObserverBridge { // |data_use_tab_model_| is notified of the matching rules on UI thread. base::WeakPtr<DataUseTabModel> data_use_tab_model_; + // The construction time of |this|. + const base::TimeTicks construct_time_; + + // True if matching rules are fetched for the first time. + bool is_first_matching_rule_fetch_; + // |io_task_runner_| accesses ExternalDataUseObserver members on IO thread. scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; diff --git a/chrome/browser/android/data_usage/external_data_use_observer_unittest.cc b/chrome/browser/android/data_usage/external_data_use_observer_unittest.cc index f13fb58..8b9205e 100644 --- a/chrome/browser/android/data_usage/external_data_use_observer_unittest.cc +++ b/chrome/browser/android/data_usage/external_data_use_observer_unittest.cc @@ -33,6 +33,11 @@ namespace { +const char kUMAMatchingRuleFirstFetchDurationHistogram[] = + "DataUsage.Perf.MatchingRuleFirstFetchDuration"; +const char kUMAReportSubmissionDurationHistogram[] = + "DataUsage.Perf.ReportSubmissionDuration"; + const char kDefaultLabel[] = "label"; const SessionID::id_type kDefaultTabId = 0; const char kDefaultURL[] = "http://www.google.com/#q=abc"; @@ -467,6 +472,7 @@ TEST_F(ExternalDataUseObserverTest, BufferDataUseReports) { histogram_tester.ExpectUniqueSample( "DataUsage.ReportSubmission.Bytes.Successful", external_data_use_observer()->data_use_report_min_bytes_, 1); + histogram_tester.ExpectTotalCount(kUMAReportSubmissionDurationHistogram, 1); // Verify that metrics were updated correctly for the report that was not // successfully submitted. @@ -479,6 +485,7 @@ TEST_F(ExternalDataUseObserverTest, BufferDataUseReports) { histogram_tester.ExpectUniqueSample( "DataUsage.ReportSubmission.Bytes.Failed", external_data_use_observer()->data_use_report_min_bytes_, 1); + histogram_tester.ExpectTotalCount(kUMAReportSubmissionDurationHistogram, 2); } #if defined(OS_ANDROID) @@ -486,6 +493,7 @@ TEST_F(ExternalDataUseObserverTest, BufferDataUseReports) { // Report should be submitted even if the number of bytes is less than the // threshold. Report should not be submitted if there is a pending report. TEST_F(ExternalDataUseObserverTest, DataUseReportingOnApplicationStatusChange) { + base::HistogramTester histogram_tester; AddDefaultMatchingRule(); TriggerTabTrackingOnDefaultTab(); @@ -507,6 +515,7 @@ TEST_F(ExternalDataUseObserverTest, DataUseReportingOnApplicationStatusChange) { EXPECT_EQ(0, external_data_use_observer()->total_bytes_buffered_); EXPECT_EQ(2, external_data_use_observer()->pending_report_bytes_); external_data_use_observer()->OnReportDataUseDone(true); + histogram_tester.ExpectTotalCount(kUMAReportSubmissionDurationHistogram, 1); // Create pending report. OnDataUse(default_data_use()); @@ -527,6 +536,7 @@ TEST_F(ExternalDataUseObserverTest, DataUseReportingOnApplicationStatusChange) { EXPECT_EQ(2, external_data_use_observer()->total_bytes_buffered_); EXPECT_EQ(default_upload_bytes() + default_download_bytes(), external_data_use_observer()->pending_report_bytes_); + histogram_tester.ExpectTotalCount(kUMAReportSubmissionDurationHistogram, 1); // Once pending report submission done callback was received, report should be // submitted on next application state change. @@ -535,6 +545,7 @@ TEST_F(ExternalDataUseObserverTest, DataUseReportingOnApplicationStatusChange) { base::android::APPLICATION_STATE_HAS_PAUSED_ACTIVITIES); EXPECT_EQ(0, external_data_use_observer()->total_bytes_buffered_); EXPECT_EQ(2, external_data_use_observer()->pending_report_bytes_); + histogram_tester.ExpectTotalCount(kUMAReportSubmissionDurationHistogram, 2); } #endif // OS_ANDROID @@ -565,15 +576,18 @@ TEST_F(ExternalDataUseObserverTest, Variations) { // Tests if the metrics are recorded correctly. TEST_F(ExternalDataUseObserverTest, DataUseReportTimedOut) { + base::HistogramTester histogram_tester; std::map<std::string, std::string> variation_params; variation_params["data_report_submit_timeout_msec"] = "0"; variation_params["data_use_report_min_bytes"] = "0"; // Create another ExternalDataUseObserver object. ReplaceExternalDataUseObserver(variation_params); + histogram_tester.ExpectTotalCount(kUMAMatchingRuleFirstFetchDurationHistogram, + 1); + AddDefaultMatchingRule(); - base::HistogramTester histogram_tester; TriggerTabTrackingOnDefaultTab(); OnDataUse(default_data_use()); OnDataUse(default_data_use()); @@ -584,6 +598,7 @@ TEST_F(ExternalDataUseObserverTest, DataUseReportTimedOut) { histogram_tester.ExpectUniqueSample( "DataUsage.ReportSubmission.Bytes.TimedOut", default_upload_bytes() + default_download_bytes(), 1); + histogram_tester.ExpectTotalCount(kUMAReportSubmissionDurationHistogram, 0); } } // namespace android diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 4dc7af8..ea047ef 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -6575,6 +6575,57 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. </summary> </histogram> +<histogram name="DataUsage.MatchingRulesCount.Invalid" units="count"> + <owner>bengr@chromium.org</owner> + <owner>rajendrant@chromium.org</owner> + <summary> + The number of invalid matching rules fetched from the platform external data + use observer. A sample is recorded everytime fetch done callback is called. + </summary> +</histogram> + +<histogram name="DataUsage.MatchingRulesCount.Valid" units="count"> + <owner>bengr@chromium.org</owner> + <owner>rajendrant@chromium.org</owner> + <summary> + The number of valid matching rules fetched from the platform external data + use observer. A sample is recorded everytime fetch done callback is called. + </summary> +</histogram> + +<histogram name="DataUsage.Perf.MatchingRuleFirstFetchDuration" units="ms"> + <owner>bengr@chromium.org</owner> + <owner>rajendrant@chromium.org</owner> + <summary> + The time taken in milliseconds to fetch the matching rules for the first + time from the platform external data use observer. This measures the + duration from the start time of Chromium to the time the rules are returned + asynchronously. A sample is recorded when the first fetch done callback is + called. + </summary> +</histogram> + +<histogram name="DataUsage.Perf.ReportSubmissionDuration" units="ms"> + <owner>bengr@chromium.org</owner> + <owner>rajendrant@chromium.org</owner> + <summary> + The time taken in milliseconds to submit the data use reports to the + platform external data use observer. This measures the duration from the + time of report submission to the time report submission done asynchronous + callback is received. A sample is recorded everytime report submission done + callback is received. + </summary> +</histogram> + +<histogram name="DataUsage.Perf.URLRegexMatchDuration" units="ms"> + <owner>bengr@chromium.org</owner> + <owner>rajendrant@chromium.org</owner> + <summary> + The time taken in milliseconds for a regular expression to parse an URL. A + sample is recorded evertime regular expression parsing is done for an URL. + </summary> +</histogram> + <histogram name="DataUsage.ReportSubmission.Bytes" units="bytes"> <owner>bengr@chromium.org</owner> <owner>tbansal@chromium.org</owner> |
