shill: Add metrics for recording termination/suspend time
Added the following metrics:
- Network.Shill.TerminationActionResult.OnSuspend,
- Network.Shill.TerminationActionResult.OnTerminate,
which log success/failure;
- Network.Shill.TerminationActionTime.OnSuspend,
- Network.Shill.TerminationActionTime.OnTerminate,
which measure the time it takes to complete the termination actions.
BUG=chromium-os:35029
TEST=Manually suspended machine and terminated shill on separate
occasions and observed the output on chrome://histograms
Change-Id: I5183d7c3dd5d4633f661598b7a0cacab6d205d8b
Reviewed-on: https://gerrit.chromium.org/gerrit/34975
Reviewed-by: Ben Chan <benchan@chromium.org>
Commit-Ready: Arman Uguray <armansito@chromium.org>
Tested-by: Arman Uguray <armansito@chromium.org>
diff --git a/shill_daemon.cc b/shill_daemon.cc
index ce8a26a..ea17007 100644
--- a/shill_daemon.cc
+++ b/shill_daemon.cc
@@ -76,18 +76,18 @@
// Stop() prevents autoconnect from attempting to immediately connect to
// services after they have been disconnected.
Stop();
- manager_->RunTerminationActions(Bind(&Daemon::TerminationActionsCompleted,
- Unretained(this)));
+ if (!manager_->RunTerminationActionsAndNotifyMetrics(
+ Bind(&Daemon::TerminationActionsCompleted, Unretained(this)),
+ Metrics::kTerminationActionReasonTerminate)) {
+ SLOG(Daemon, 1) << "No termination actions were run";
+ dispatcher_.PostTask(MessageLoop::QuitClosure());
+ }
}
-void Daemon::TerminationActionsCompleted(const Error & error) {
+void Daemon::TerminationActionsCompleted(const Error &error) {
SLOG(Daemon, 1) << "Finished termination actions. Result: " << error;
- Metrics::TerminationActionResult result = error.IsSuccess() ?
- Metrics::kTerminationActionSuccess :
- Metrics::kTerminationActionFailure;
- metrics_.SendEnumToUMA(Metrics::kMetricTerminationActionResult,
- result,
- Metrics::kTerminationActionResultMax);
+ metrics_.NotifyTerminationActionsCompleted(
+ Metrics::kTerminationActionReasonTerminate, error.IsSuccess());
dispatcher_.PostTask(MessageLoop::QuitClosure());
}