Commit 019ae61f authored by Xing Liu's avatar Xing Liu Committed by Commit Bot

Notification scheduler: Add database metrics.

This CL adds metrics to track two level db we use in notification
scheduling system.

TBR=dtrainor@chromium.org

Bug: 963298
Change-Id: I6e0698827b0ef5450df1c23abca8f94168086e09
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1761651
Commit-Queue: Xing Liu <xingliu@chromium.org>
Reviewed-by: default avatarHesen Zhang <hesen@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689100}
parent 56e6bbbd
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/numerics/ranges.h" #include "base/numerics/ranges.h"
#include "chrome/browser/notifications/scheduler/internal/scheduler_utils.h" #include "chrome/browser/notifications/scheduler/internal/scheduler_utils.h"
#include "chrome/browser/notifications/scheduler/internal/stats.h"
namespace notifications { namespace notifications {
namespace { namespace {
...@@ -139,6 +140,8 @@ void ImpressionHistoryTrackerImpl::OnStoreInitialized( ...@@ -139,6 +140,8 @@ void ImpressionHistoryTrackerImpl::OnStoreInitialized(
InitCallback callback, InitCallback callback,
bool success, bool success,
CollectionStore<ClientState>::Entries entries) { CollectionStore<ClientState>::Entries entries) {
stats::LogImpressionDbInit(success, entries.size());
if (!success) { if (!success) {
std::move(callback).Run(false); std::move(callback).Run(false);
return; return;
...@@ -179,7 +182,8 @@ void ImpressionHistoryTrackerImpl::SyncRegisteredClients() { ...@@ -179,7 +182,8 @@ void ImpressionHistoryTrackerImpl::SyncRegisteredClients() {
std::find(registered_clients_.begin(), registered_clients_.end(), std::find(registered_clients_.begin(), registered_clients_.end(),
client_type) == registered_clients_.end(); client_type) == registered_clients_.end();
if (deprecated) { if (deprecated) {
store_->Delete(ToDatabaseKey(client_type), base::DoNothing()); store_->Delete(ToDatabaseKey(client_type),
base::BindOnce(&stats::LogImpressionDbOperation));
client_states_.erase(it++); client_states_.erase(it++);
continue; continue;
} else { } else {
...@@ -194,7 +198,7 @@ void ImpressionHistoryTrackerImpl::SyncRegisteredClients() { ...@@ -194,7 +198,7 @@ void ImpressionHistoryTrackerImpl::SyncRegisteredClients() {
DCHECK(new_client_data); DCHECK(new_client_data);
store_->Add(ToDatabaseKey(type), *new_client_data.get(), store_->Add(ToDatabaseKey(type), *new_client_data.get(),
base::DoNothing()); base::BindOnce(&stats::LogImpressionDbOperation));
client_states_.emplace(type, std::move(new_client_data)); client_states_.emplace(type, std::move(new_client_data));
} }
} }
...@@ -398,7 +402,8 @@ bool ImpressionHistoryTrackerImpl::MaybeUpdateDb(SchedulerClientType type) { ...@@ -398,7 +402,8 @@ bool ImpressionHistoryTrackerImpl::MaybeUpdateDb(SchedulerClientType type) {
bool db_updated = false; bool db_updated = false;
if (NeedsUpdate(type)) { if (NeedsUpdate(type)) {
store_->Update(ToDatabaseKey(type), *(it->second.get()), base::DoNothing()); store_->Update(ToDatabaseKey(type), *(it->second.get()),
base::BindOnce(&stats::LogImpressionDbOperation));
db_updated = true; db_updated = true;
} }
SetNeedsUpdate(type, false); SetNeedsUpdate(type, false);
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "chrome/browser/notifications/scheduler/internal/notification_entry.h" #include "chrome/browser/notifications/scheduler/internal/notification_entry.h"
#include "chrome/browser/notifications/scheduler/internal/scheduler_config.h" #include "chrome/browser/notifications/scheduler/internal/scheduler_config.h"
#include "chrome/browser/notifications/scheduler/internal/scheduler_utils.h" #include "chrome/browser/notifications/scheduler/internal/scheduler_utils.h"
#include "chrome/browser/notifications/scheduler/internal/stats.h"
#include "chrome/browser/notifications/scheduler/public/notification_params.h" #include "chrome/browser/notifications/scheduler/public/notification_params.h"
#include "chrome/browser/notifications/scheduler/public/notification_scheduler_constant.h" #include "chrome/browser/notifications/scheduler/public/notification_scheduler_constant.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
...@@ -194,6 +195,8 @@ class ScheduledNotificationManagerImpl : public ScheduledNotificationManager { ...@@ -194,6 +195,8 @@ class ScheduledNotificationManagerImpl : public ScheduledNotificationManager {
InitCallback callback, InitCallback callback,
bool success, bool success,
CollectionStore<NotificationEntry>::Entries entries) { CollectionStore<NotificationEntry>::Entries entries) {
stats::LogNotificationDbInit(success, entries.size());
if (!success) { if (!success) {
std::move(callback).Run(false); std::move(callback).Run(false);
return; return;
...@@ -228,6 +231,7 @@ class ScheduledNotificationManagerImpl : public ScheduledNotificationManager { ...@@ -228,6 +231,7 @@ class ScheduledNotificationManagerImpl : public ScheduledNotificationManager {
void OnNotificationAdded(SchedulerClientType type, void OnNotificationAdded(SchedulerClientType type,
std::string guid, std::string guid,
bool success) { bool success) {
stats::LogNotificationDbOperation(success);
auto* entry = FindNotificationEntry(type, guid); auto* entry = FindNotificationEntry(type, guid);
if (!entry) if (!entry)
return; return;
...@@ -247,7 +251,9 @@ class ScheduledNotificationManagerImpl : public ScheduledNotificationManager { ...@@ -247,7 +251,9 @@ class ScheduledNotificationManagerImpl : public ScheduledNotificationManager {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
void OnNotificationDeleted(bool success) { NOTIMPLEMENTED(); } void OnNotificationDeleted(bool success) {
stats::LogNotificationDbOperation(success);
}
void OnIconDeleted(bool success) { NOTIMPLEMENTED(); } void OnIconDeleted(bool success) { NOTIMPLEMENTED(); }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "chrome/browser/notifications/scheduler/internal/stats.h" #include "chrome/browser/notifications/scheduler/internal/stats.h"
#include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
namespace notifications { namespace notifications {
namespace stats { namespace stats {
...@@ -34,5 +35,33 @@ void LogUserAction(const UserActionData& action_data) { ...@@ -34,5 +35,33 @@ void LogUserAction(const UserActionData& action_data) {
base::UmaHistogramEnumeration(name, action_data.action_type); base::UmaHistogramEnumeration(name, action_data.action_type);
} }
void LogImpressionDbInit(bool success, int entry_count) {
UMA_HISTOGRAM_BOOLEAN("Notifications.Scheduler.ImpressionDb.InitResult",
success);
if (success) {
UMA_HISTOGRAM_COUNTS_100("Notifications.Scheduler.ImpressionDb.RecordCount",
entry_count);
}
}
void LogImpressionDbOperation(bool success) {
UMA_HISTOGRAM_BOOLEAN("Notifications.Scheduler.ImpressionDb.OperationResult",
success);
}
void LogNotificationDbInit(bool success, int entry_count) {
UMA_HISTOGRAM_BOOLEAN("Notifications.Scheduler.NotificationDb.InitResult",
success);
if (success) {
UMA_HISTOGRAM_COUNTS_100(
"Notifications.Scheduler.NotificationDb.RecordCount", entry_count);
}
}
void LogNotificationDbOperation(bool success) {
UMA_HISTOGRAM_BOOLEAN(
"Notifications.Scheduler.NotificationDb.OperationResult", success);
}
} // namespace stats } // namespace stats
} // namespace notifications } // namespace notifications
...@@ -14,6 +14,18 @@ namespace stats { ...@@ -14,6 +14,18 @@ namespace stats {
// scheduling system. // scheduling system.
void LogUserAction(const UserActionData& user_action_data); void LogUserAction(const UserActionData& user_action_data);
// Logs the initialization result for impression database.
void LogImpressionDbInit(bool success, int entry_count);
// Logs impression db operations result except the initialization.
void LogImpressionDbOperation(bool success);
// Logs the initialization result for notification database.
void LogNotificationDbInit(bool success, int entry_count);
// Logs notification db operations result except the initialization.
void LogNotificationDbOperation(bool success);
} // namespace stats } // namespace stats
} // namespace notifications } // namespace notifications
......
...@@ -86573,6 +86573,66 @@ uploading your change for review. ...@@ -86573,6 +86573,66 @@ uploading your change for review.
</summary> </summary>
</histogram> </histogram>
<histogram name="Notifications.Scheduler.ImpressionDb.InitResult"
enum="BooleanSuccess" expires_after="2020-08-01">
<owner>xingliu@chromium.org</owner>
<owner>hesen@chromium.org</owner>
<summary>
Records the initialization result of impression database for the
notification scheduling system.
</summary>
</histogram>
<histogram name="Notifications.Scheduler.ImpressionDb.OperationResult"
enum="BooleanSuccess" expires_after="2020-08-01">
<owner>xingliu@chromium.org</owner>
<owner>hesen@chromium.org</owner>
<summary>
Records the database operation result (except initialization) of impression
database for the notification scheduling system.
</summary>
</histogram>
<histogram name="Notifications.Scheduler.ImpressionDb.RecordCount"
units="records" expires_after="2020-08-01">
<owner>xingliu@chromium.org</owner>
<owner>hesen@chromium.org</owner>
<summary>
Records the number of records of impression database for the notification
scheduling system.
</summary>
</histogram>
<histogram name="Notifications.Scheduler.NotificationDb.InitResult"
enum="BooleanSuccess" expires_after="2020-08-01">
<owner>xingliu@chromium.org</owner>
<owner>hesen@chromium.org</owner>
<summary>
Records the initialization result of notification database for the
notification scheduling system.
</summary>
</histogram>
<histogram name="Notifications.Scheduler.NotificationDb.OperationResult"
enum="BooleanSuccess" expires_after="2020-08-01">
<owner>xingliu@chromium.org</owner>
<owner>hesen@chromium.org</owner>
<summary>
Records the database operation result (except initialization) of
notification database for the notification scheduling system.
</summary>
</histogram>
<histogram name="Notifications.Scheduler.NotificationDb.RecordCount"
units="records" expires_after="2020-08-01">
<owner>xingliu@chromium.org</owner>
<owner>hesen@chromium.org</owner>
<summary>
Records the number of records of notification database for the notification
scheduling system.
</summary>
</histogram>
<histogram name="Notifications.Scheduler.UserAction" <histogram name="Notifications.Scheduler.UserAction"
enum="NotificationSchedulerUserActionType" expires_after="2020-08-01"> enum="NotificationSchedulerUserActionType" expires_after="2020-08-01">
<!-- Name completed by histogram_suffixes name="NotificationSchedulerClientType" --> <!-- Name completed by histogram_suffixes name="NotificationSchedulerClientType" -->
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