summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsorin <sorin@chromium.org>2016-03-09 16:32:48 -0800
committerCommit bot <commit-bot@chromium.org>2016-03-10 00:33:39 +0000
commit85953dcfa85e670b776e8389845a640ef6bb8fa4 (patch)
tree9f11951ba817f6cbc995be6a955b0d64ac17dd40
parentb9d266457c4b0b619304c99a28fce037be7b0507 (diff)
downloadchromium_src-85953dcfa85e670b776e8389845a640ef6bb8fa4.zip
chromium_src-85953dcfa85e670b776e8389845a640ef6bb8fa4.tar.gz
chromium_src-85953dcfa85e670b776e8389845a640ef6bb8fa4.tar.bz2
Define a few simple UMA metrics for the component updater.
* number of updates * number of installs (on-demand updates) * completions success/error * completion duration BUG=593191 Review URL: https://codereview.chromium.org/1777793002 Cr-Commit-Position: refs/heads/master@{#380272}
-rw-r--r--components/component_updater/component_updater_service.cc32
-rw-r--r--components/component_updater/component_updater_service_internal.h10
-rw-r--r--components/component_updater/component_updater_service_unittest.cc23
-rw-r--r--tools/metrics/histograms/histograms.xml27
4 files changed, 86 insertions, 6 deletions
diff --git a/components/component_updater/component_updater_service.cc b/components/component_updater/component_updater_service.cc
index fce7e99..8f0515bd 100644
--- a/components/component_updater/component_updater_service.cc
+++ b/components/component_updater/component_updater_service.cc
@@ -18,11 +18,13 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
+#include "base/metrics/histogram_macros.h"
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread_checker.h"
+#include "base/time/time.h"
#include "base/timer/timer.h"
#include "components/component_updater/component_updater_service_internal.h"
#include "components/component_updater/timer.h"
@@ -35,6 +37,16 @@
using CrxInstaller = update_client::CrxInstaller;
using UpdateClient = update_client::UpdateClient;
+namespace {
+
+enum UpdateType {
+ UPDATE_TYPE_MANUAL = 0,
+ UPDATE_TYPE_AUTOMATIC,
+ UPDATE_TYPE_COUNT,
+};
+
+} // namespace
+
namespace component_updater {
CrxUpdateService::CrxUpdateService(
@@ -235,15 +247,23 @@ bool CrxUpdateService::OnDemandUpdateWithCooldown(const std::string& id) {
bool CrxUpdateService::OnDemandUpdateInternal(const std::string& id) {
DCHECK(thread_checker_.CalledOnValidThread());
+ UMA_HISTOGRAM_ENUMERATION("ComponentUpdater.Calls", UPDATE_TYPE_MANUAL,
+ UPDATE_TYPE_COUNT);
+
update_client_->Install(
id, base::Bind(&CrxUpdateService::OnUpdate, base::Unretained(this)),
- base::Bind(&CrxUpdateService::OnUpdateComplete, base::Unretained(this)));
+ base::Bind(&CrxUpdateService::OnUpdateComplete, base::Unretained(this),
+ base::TimeTicks::Now()));
return true;
}
bool CrxUpdateService::CheckForUpdates() {
DCHECK(thread_checker_.CalledOnValidThread());
+
+ UMA_HISTOGRAM_ENUMERATION("ComponentUpdater.Calls", UPDATE_TYPE_AUTOMATIC,
+ UPDATE_TYPE_COUNT);
+
std::vector<std::string> ids;
for (const auto id : components_order_) {
DCHECK(components_.find(id) != components_.end());
@@ -252,7 +272,8 @@ bool CrxUpdateService::CheckForUpdates() {
update_client_->Update(
ids, base::Bind(&CrxUpdateService::OnUpdate, base::Unretained(this)),
- base::Bind(&CrxUpdateService::OnUpdateComplete, base::Unretained(this)));
+ base::Bind(&CrxUpdateService::OnUpdateComplete, base::Unretained(this),
+ base::TimeTicks::Now()));
return true;
}
@@ -296,10 +317,15 @@ void CrxUpdateService::OnUpdate(const std::vector<std::string>& ids,
}
}
-void CrxUpdateService::OnUpdateComplete(int error) {
+void CrxUpdateService::OnUpdateComplete(const base::TimeTicks& start_time,
+ int error) {
DCHECK(thread_checker_.CalledOnValidThread());
VLOG(1) << "Update completed with error " << error;
+ UMA_HISTOGRAM_BOOLEAN("ComponentUpdater.UpdateCompleteResult", error != 0);
+ UMA_HISTOGRAM_LONG_TIMES_100("ComponentUpdater.UpdateCompleteTime",
+ base::TimeTicks::Now() - start_time);
+
for (const auto id : components_pending_unregistration_) {
if (!update_client_->IsUpdating(id)) {
const auto component = GetComponent(id);
diff --git a/components/component_updater/component_updater_service_internal.h b/components/component_updater/component_updater_service_internal.h
index 29c5d31..3e262c0 100644
--- a/components/component_updater/component_updater_service_internal.h
+++ b/components/component_updater/component_updater_service_internal.h
@@ -17,6 +17,10 @@
#include "base/threading/thread_checker.h"
#include "components/component_updater/timer.h"
+namespace base {
+class TimeTicks;
+}
+
namespace component_updater {
class OnDemandUpdater;
@@ -44,13 +48,15 @@ class CrxUpdateService : public ComponentUpdateService,
void MaybeThrottle(const std::string& id,
const base::Closure& callback) override;
scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner() override;
- bool OnDemandUpdate(const std::string& id) override;
bool GetComponentDetails(const std::string& id,
CrxUpdateItem* item) const override;
// Overrides for Observer.
void OnEvent(Events event, const std::string& id) override;
+ // Overrides for OnDemandUpdater.
+ bool OnDemandUpdate(const std::string& id) override;
+
private:
void Start();
void Stop();
@@ -68,7 +74,7 @@ class CrxUpdateService : public ComponentUpdateService,
void OnUpdate(const std::vector<std::string>& ids,
std::vector<CrxComponent>* components);
- void OnUpdateComplete(int error);
+ void OnUpdateComplete(const base::TimeTicks& start_time, int error);
base::ThreadChecker thread_checker_;
diff --git a/components/component_updater/component_updater_service_unittest.cc b/components/component_updater/component_updater_service_unittest.cc
index 15b62bb..83d5874 100644
--- a/components/component_updater/component_updater_service_unittest.cc
+++ b/components/component_updater/component_updater_service_unittest.cc
@@ -15,6 +15,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
+#include "base/test/histogram_tester.h"
#include "base/test/sequenced_worker_pool_owner.h"
#include "base/thread_task_runner_handle.h"
#include "base/values.h"
@@ -215,6 +216,7 @@ TEST_F(ComponentUpdaterTest, RegisterComponent) {
void OnUpdate(const std::vector<std::string>& ids,
const UpdateClient::CrxDataCallback& crx_data_callback,
const UpdateClient::CompletionCallback& completion_callback) {
+ completion_callback.Run(0);
static int cnt = 0;
++cnt;
if (cnt >= max_cnt_)
@@ -226,6 +228,8 @@ TEST_F(ComponentUpdaterTest, RegisterComponent) {
base::Closure quit_closure_;
};
+ base::HistogramTester ht;
+
scoped_refptr<MockInstaller> installer(new MockInstaller());
EXPECT_CALL(*installer, Uninstall()).WillOnce(Return(true));
@@ -260,8 +264,11 @@ TEST_F(ComponentUpdaterTest, RegisterComponent) {
EXPECT_TRUE(component_updater().RegisterComponent(crx_component2));
RunThreads();
-
EXPECT_TRUE(component_updater().UnregisterComponent(id1));
+
+ ht.ExpectUniqueSample("ComponentUpdater.Calls", 1, 2);
+ ht.ExpectUniqueSample("ComponentUpdater.UpdateCompleteResult", 0, 2);
+ ht.ExpectTotalCount("ComponentUpdater.UpdateCompleteTime", 2);
}
// Tests that on-demand updates invoke UpdateClient::Install.
@@ -275,6 +282,7 @@ TEST_F(ComponentUpdaterTest, OnDemandUpdate) {
const std::string& ids,
const UpdateClient::CrxDataCallback& crx_data_callback,
const UpdateClient::CompletionCallback& completion_callback) {
+ completion_callback.Run(0);
static int cnt = 0;
++cnt;
if (cnt >= max_cnt_)
@@ -286,6 +294,8 @@ TEST_F(ComponentUpdaterTest, OnDemandUpdate) {
base::Closure quit_closure_;
};
+ base::HistogramTester ht;
+
auto config = configurator();
config->SetInitialDelay(3600);
@@ -312,6 +322,10 @@ TEST_F(ComponentUpdaterTest, OnDemandUpdate) {
EXPECT_TRUE(OnDemandTester::OnDemand(&cus, id));
RunThreads();
+
+ ht.ExpectUniqueSample("ComponentUpdater.Calls", 0, 1);
+ ht.ExpectUniqueSample("ComponentUpdater.UpdateCompleteResult", 0, 1);
+ ht.ExpectTotalCount("ComponentUpdater.UpdateCompleteTime", 1);
}
// Tests that throttling an update invokes UpdateClient::Install.
@@ -325,6 +339,7 @@ TEST_F(ComponentUpdaterTest, MaybeThrottle) {
const std::string& ids,
const UpdateClient::CrxDataCallback& crx_data_callback,
const UpdateClient::CompletionCallback& completion_callback) {
+ completion_callback.Run(0);
static int cnt = 0;
++cnt;
if (cnt >= max_cnt_)
@@ -336,6 +351,8 @@ TEST_F(ComponentUpdaterTest, MaybeThrottle) {
base::Closure quit_closure_;
};
+ base::HistogramTester ht;
+
auto config = configurator();
config->SetInitialDelay(3600);
@@ -359,6 +376,10 @@ TEST_F(ComponentUpdaterTest, MaybeThrottle) {
base::Bind(&ComponentUpdaterTest::ReadyCallback));
RunThreads();
+
+ ht.ExpectUniqueSample("ComponentUpdater.Calls", 0, 1);
+ ht.ExpectUniqueSample("ComponentUpdater.UpdateCompleteResult", 0, 1);
+ ht.ExpectTotalCount("ComponentUpdater.UpdateCompleteTime", 1);
}
} // namespace component_updater
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index 72c5dbd..02913bc 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -5138,6 +5138,28 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<summary>Number of tries before successful ping. 99 means giving up.</summary>
</histogram>
+<histogram name="ComponentUpdater.Calls" enum="ComponentUpdaterCalls">
+ <owner>sorin@chromium.org</owner>
+ <summary>
+ The number of times the component updater called UpdateClient::Install or
+ UpdateClient::Update. These correspond to the number of manual component
+ update checks performed as a result of a user action, and the number of
+ automated component update checks.
+ </summary>
+</histogram>
+
+<histogram name="ComponentUpdater.UpdateCompleteResult" enum="BooleanError">
+ <owner>sorin@chromium.org</owner>
+ <summary>The result of an install or an update check.</summary>
+</histogram>
+
+<histogram name="ComponentUpdater.UpdateCompleteTime" units="ms">
+ <owner>sorin@chromium.org</owner>
+ <summary>
+ Time to complete an Install or an Update component update call.
+ </summary>
+</histogram>
+
<histogram
name="Compositing.Browser.DisplayListRecordingSource.UpdateInvalidatedAreaPerMs"
units="pixels/ms">
@@ -61278,6 +61300,11 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<int value="2" label="Successful first layout"/>
</enum>
+<enum name="ComponentUpdaterCalls" type="int">
+ <int value="0" label="Install"/>
+ <int value="1" label="Update"/>
+</enum>
+
<enum name="CompositedScrolling" type="int">
<int value="0" label="Is scrollable area"/>
<int value="1" label="Needs to be stacking container"/>