Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Unified Diff: components/ntp_snippets/ntp_snippets_fetcher.cc

Issue 1937063002: [NTP Snippets] Add metric for fetch error cases (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@record_article_fetch_errors_0
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/ntp_snippets/ntp_snippets_fetcher_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/ntp_snippets_fetcher.cc
diff --git a/components/ntp_snippets/ntp_snippets_fetcher.cc b/components/ntp_snippets/ntp_snippets_fetcher.cc
index 7fe3d94b0e54b22c86e052357ff1bf1e2a1f0f48..63826de5a72857903a2615c7749ad6d8189b00d8 100644
--- a/components/ntp_snippets/ntp_snippets_fetcher.cc
+++ b/components/ntp_snippets/ntp_snippets_fetcher.cc
@@ -6,6 +6,7 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
+#include "base/metrics/sparse_histogram.h"
#include "base/path_service.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
@@ -120,12 +121,21 @@ void NTPSnippetsFetcher::OnURLFetchComplete(const URLFetcher* source) {
std::string message;
const URLRequestStatus& status = source->GetStatus();
+
if (!status.is_success()) {
+ UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.Snippets.FailedRequestErrorCode",
+ -status.error());
Marc Treib 2016/05/02 14:41:22 I assume the minus is because the error codes tend
mastiz 2016/05/02 15:11:44 Although it's not explicitly documented, URLReques
Marc Treib 2016/05/02 15:20:56 Alright then. Maybe worth a comment?
+
message = base::StringPrintf(kStatusMessageURLRequestErrorFormat,
status.error());
- } else if (source->GetResponseCode() != net::HTTP_OK) {
- message = base::StringPrintf(kStatusMessageHTTPErrorFormat,
- source->GetResponseCode());
+ } else {
+ UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.Snippets.FetchResponseCode",
+ source->GetResponseCode());
Marc Treib 2016/05/02 14:41:22 So this one is recorded on success too, which prob
mastiz 2016/05/02 15:11:44 You're right, the description was outdated, thanks
+
+ if (source->GetResponseCode() != net::HTTP_OK) {
+ message = base::StringPrintf(kStatusMessageHTTPErrorFormat,
+ source->GetResponseCode());
+ }
}
std::string response;
« no previous file with comments | « no previous file | components/ntp_snippets/ntp_snippets_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698