Add Installer.[Full]PayloadAttemptNumber
This patch adds two new metrics with the attempt number of the
current payload. The difference with other similar metrics, like
Installer.AttemptsCount.Total is that this metric is send every
time the PayloadAttemptNumber is incremented, tracking also
abandoned payload attempts.
BUG=chromium:225973
TEST=cros_workon_make update_engine --test
Change-Id: I96828fdf0512bac0e04c63a40383ac46143c5908
Reviewed-on: https://gerrit.chromium.org/gerrit/61344
Commit-Queue: Alex Deymo <deymo@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
diff --git a/payload_state.cc b/payload_state.cc
index 6851fcb..8c2547f 100644
--- a/payload_state.cc
+++ b/payload_state.cc
@@ -324,6 +324,18 @@
void PayloadState::IncrementPayloadAttemptNumber() {
// Update the payload attempt number for both payload types: full and delta.
SetPayloadAttemptNumber(GetPayloadAttemptNumber() + 1);
+
+ // Report the metric every time the value is incremented.
+ string metric = "Installer.PayloadAttemptNumber";
+ int value = GetPayloadAttemptNumber();
+
+ LOG(INFO) << "Uploading " << value << " (count) for metric " << metric;
+ system_state_->metrics_lib()->SendToUMA(
+ metric,
+ value,
+ 1, // min value
+ 50, // max value
+ kNumDefaultUmaBuckets);
}
void PayloadState::IncrementFullPayloadAttemptNumber() {
@@ -333,9 +345,21 @@
return;
}
- LOG(INFO) << "Incrementing the payload attempt number";
+ LOG(INFO) << "Incrementing the full payload attempt number";
SetFullPayloadAttemptNumber(GetFullPayloadAttemptNumber() + 1);
UpdateBackoffExpiryTime();
+
+ // Report the metric every time the value is incremented.
+ string metric = "Installer.FullPayloadAttemptNumber";
+ int value = GetFullPayloadAttemptNumber();
+
+ LOG(INFO) << "Uploading " << value << " (count) for metric " << metric;
+ system_state_->metrics_lib()->SendToUMA(
+ metric,
+ value,
+ 1, // min value
+ 50, // max value
+ kNumDefaultUmaBuckets);
}
void PayloadState::IncrementUrlIndex() {
@@ -348,8 +372,8 @@
<< "0 as we only have " << candidate_urls_.size()
<< " candidate URL(s)";
SetUrlIndex(0);
- IncrementPayloadAttemptNumber();
- IncrementFullPayloadAttemptNumber();
+ IncrementPayloadAttemptNumber();
+ IncrementFullPayloadAttemptNumber();
}
// If we have multiple URLs, record that we just switched to another one