Commit d8840694 authored by zea@chromium.org's avatar zea@chromium.org

[GCM] Add connection/persistent store metric collection

Adds various metrics related to GCM connection stability and persistent store
usage.

BUG=284553

Review URL: https://codereview.chromium.org/123453004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243501 0039d316-1c4b-4281-b951-d872f2087c98
parent 73e6e0f3
......@@ -5,6 +5,8 @@
#include "google_apis/gcm/engine/connection_factory_impl.h"
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/metrics/sparse_histogram.h"
#include "google_apis/gcm/engine/connection_handler_impl.h"
#include "google_apis/gcm/protocol/mcs.pb.h"
#include "net/base/net_errors.h"
......@@ -211,6 +213,7 @@ void ConnectionFactoryImpl::OnConnectDone(int result) {
if (result != net::OK) {
LOG(ERROR) << "Failed to connect to MCS endpoint with error " << result;
backoff_entry_->InformOfRequest(false);
UMA_HISTOGRAM_SPARSE_SLOWLY("GCM.ConnectionFailureErrorCode", result);
Connect();
return;
}
......@@ -228,6 +231,10 @@ void ConnectionFactoryImpl::ConnectionHandlerCallback(int result) {
backoff_entry_->Reset();
return;
}
if (!connecting_)
UMA_HISTOGRAM_SPARSE_SLOWLY("GCM.ConnectionDisconnectErrorCode", result);
// TODO(zea): Consider how to handle errors that may require some sort of
// user intervention (login page, etc.).
LOG(ERROR) << "Connection reset with error " << result;
......
......@@ -7,9 +7,11 @@
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/callback.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/metrics/histogram.h"
#include "base/sequenced_task_runner.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
......@@ -141,6 +143,7 @@ void GCMStoreImpl::Backend::Load(const LoadCallback& callback) {
leveldb::DB* db;
leveldb::Status status =
leveldb::DB::Open(options, path_.AsUTF8Unsafe(), &db);
UMA_HISTOGRAM_BOOLEAN("GCM.LoadSucceeded", status.ok());
if (!status.ok()) {
LOG(ERROR) << "Failed to open database " << path_.value() << ": "
<< status.ToString();
......@@ -165,6 +168,21 @@ void GCMStoreImpl::Backend::Load(const LoadCallback& callback) {
return;
}
// Only record histograms if GCM had already been set up for this device.
if (result.device_android_id != 0 && result.device_security_token != 0) {
int64 file_size = 0;
if (base::GetFileSize(path_, &file_size)) {
UMA_HISTOGRAM_COUNTS("GCM.StoreSizeKB",
static_cast<int>(file_size / 1024));
}
UMA_HISTOGRAM_COUNTS("GCM.RestoredOutgoingMessages",
result.outgoing_messages.size());
UMA_HISTOGRAM_COUNTS("GCM.RestoredIncomingMessages",
result.incoming_messages.size());
UMA_HISTOGRAM_COUNTS("GCM.NumUsers", result.user_serial_numbers.size());
}
DVLOG(1) << "Succeeded in loading " << result.incoming_messages.size()
<< " unacknowledged incoming messages and "
<< result.outgoing_messages.size()
......
......@@ -6,6 +6,7 @@
#include "base/basictypes.h"
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/strings/string_number_conversions.h"
#include "base/time/clock.h"
#include "base/time/time.h"
......@@ -345,6 +346,7 @@ void MCSClient::SendHeartbeat() {
void MCSClient::OnGCMUpdateFinished(bool success) {
LOG_IF(ERROR, !success) << "GCM Update failed!";
UMA_HISTOGRAM_BOOLEAN("GCM.StoreUpdateSucceeded", success);
// TODO(zea): Rebuild the store from scratch in case of persistence failure?
}
......
......@@ -5376,6 +5376,52 @@ other types of suffix sets.
</summary>
</histogram>
<histogram name="GCM.ConnectionDisconnectErrorCode" enum="NetErrorCodes">
<summary>Net error results from GCM disconnect events.</summary>
</histogram>
<histogram name="GCM.ConnectionFailureErrorCode" enum="NetErrorCodes">
<summary>Net error results from GCM connection attempts.</summary>
</histogram>
<histogram name="GCM.NumUsers">
<summary>
Number of GCM users associated with this client at startup time.
</summary>
</histogram>
<histogram name="GCM.RestoredIncomingMessages">
<summary>
Number of unacknowledged incoming messages restored from the persistent
store at startup.
</summary>
</histogram>
<histogram name="GCM.RestoredOutgoingMessages">
<summary>
Number of pending outgoing messages restored from the persistent store at
startup.
</summary>
</histogram>
<histogram name="GCM.StoreLoadSucceeded" enum="BooleanSuccess">
<summary>
Success indicates successfully loading an initialized persistent GCM store
at startup time. Failure indicates a failure loading the store.
</summary>
</histogram>
<histogram name="GCM.StoreSizeKB" units="kilobytes">
<summary>Size of the GCM persistent store in kilobytes at startup.</summary>
</histogram>
<histogram name="GCM.StoreUpdateSucceeded" enum="BooleanSuccess">
<summary>
Success indicates successfully updating the GCM persistent store on message
update. Failure indicates a failure updating the persistence store.
</summary>
</histogram>
<histogram name="GData.AuthSuccess" enum="GDataAuthResult">
<summary>Result of the authentication for Drive.</summary>
</histogram>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment