Commit ad6fc44c authored by davidben's avatar davidben Committed by Commit bot

Replace GetAllErrorCodesForUma calls with UMA_HISTOGRAM_SPARSE_SLOWLY.

Per review comment on https://codereview.chromium.org/1127623005/, sparse
histograms are preferred.

BUG=none

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

Cr-Commit-Position: refs/heads/master@{#330417}
parent 16e43b89
......@@ -17,7 +17,8 @@
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/scoped_vector.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/sparse_histogram.h"
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
#include "base/values.h"
......@@ -346,24 +347,19 @@ scoped_ptr<ErrorPageParams> CreateErrorPageParams(
void ReportAutoReloadSuccess(const blink::WebURLError& error, size_t count) {
if (error.domain.utf8() != net::kErrorDomain)
return;
UMA_HISTOGRAM_CUSTOM_ENUMERATION("Net.AutoReload.ErrorAtSuccess",
-error.reason,
net::GetAllErrorCodesForUma());
UMA_HISTOGRAM_SPARSE_SLOWLY("Net.AutoReload.ErrorAtSuccess", -error.reason);
UMA_HISTOGRAM_COUNTS("Net.AutoReload.CountAtSuccess",
static_cast<base::HistogramBase::Sample>(count));
if (count == 1) {
UMA_HISTOGRAM_CUSTOM_ENUMERATION("Net.AutoReload.ErrorAtFirstSuccess",
-error.reason,
net::GetAllErrorCodesForUma());
UMA_HISTOGRAM_SPARSE_SLOWLY("Net.AutoReload.ErrorAtFirstSuccess",
-error.reason);
}
}
void ReportAutoReloadFailure(const blink::WebURLError& error, size_t count) {
if (error.domain.utf8() != net::kErrorDomain)
return;
UMA_HISTOGRAM_CUSTOM_ENUMERATION("Net.AutoReload.ErrorAtStop",
-error.reason,
net::GetAllErrorCodesForUma());
UMA_HISTOGRAM_SPARSE_SLOWLY("Net.AutoReload.ErrorAtStop", -error.reason);
UMA_HISTOGRAM_COUNTS("Net.AutoReload.CountAtStop",
static_cast<base::HistogramBase::Sample>(count));
}
......
......@@ -9,7 +9,8 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/sparse_histogram.h"
#include "base/strings/stringprintf.h"
#include "content/browser/byte_stream.h"
#include "content/browser/download/download_create_info.h"
......@@ -453,9 +454,8 @@ void DownloadResourceHandler::OnResponseCompleted(
// If the error mapped to something unknown, record it so that
// we can drill down.
if (reason == DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED) {
UMA_HISTOGRAM_CUSTOM_ENUMERATION("Download.MapErrorNetworkFailed",
std::abs(status.error()),
net::GetAllErrorCodesForUma());
UMA_HISTOGRAM_SPARSE_SLOWLY("Download.MapErrorNetworkFailed",
std::abs(status.error()));
}
stream_writer_.reset(); // We no longer need the stream.
......
......@@ -4,22 +4,6 @@
#include "net/base/net_errors.h"
#include "base/basictypes.h"
#include "base/metrics/histogram.h"
#include "base/strings/stringize_macros.h"
namespace {
// Get all valid error codes into an array as positive numbers, for use in the
// |GetAllErrorCodesForUma| function below.
#define NET_ERROR(label, value) -(value),
const int kAllErrorCodes[] = {
#include "net/base/net_error_list.h"
};
#undef NET_ERROR
} // namespace
namespace net {
const char kErrorDomain[] = "net";
......@@ -68,11 +52,6 @@ bool IsClientCertificateError(int error) {
}
}
std::vector<int> GetAllErrorCodesForUma() {
return base::CustomHistogram::ArrayToCustomRanges(
kAllErrorCodes, arraysize(kAllErrorCodes));
}
Error FileErrorToNetError(base::File::Error file_error) {
switch (file_error) {
case base::File::FILE_OK:
......
......@@ -48,15 +48,6 @@ NET_EXPORT bool IsClientCertificateError(int error);
// Map system error code to Error.
NET_EXPORT Error MapSystemError(logging::SystemErrorCode os_error);
// Returns a list of all the possible net error codes (not counting OK). This
// is intended for use with UMA histograms that are reporting the result of
// an action that is represented as a net error code.
//
// Note that the error codes are all positive (since histograms expect positive
// sample values). Also note that a guard bucket is created after any valid
// error code that is not followed immediately by a valid error code.
NET_EXPORT std::vector<int> GetAllErrorCodesForUma();
// A convenient function to translate file error to net error code.
NET_EXPORT Error FileErrorToNetError(base::File::Error file_error);
......
......@@ -23,7 +23,8 @@
#include "base/debug/stack_trace.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/sparse_histogram.h"
#include "base/profiler/scoped_tracker.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
......@@ -1553,9 +1554,8 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
} else {
UmaAsyncDnsResolveStatus(RESOLVE_STATUS_PROC_SUCCESS);
}
UMA_HISTOGRAM_CUSTOM_ENUMERATION("AsyncDNS.ResolveError",
std::abs(dns_task_error_),
GetAllErrorCodesForUma());
UMA_HISTOGRAM_SPARSE_SLOWLY("AsyncDNS.ResolveError",
std::abs(dns_task_error_));
resolver_->OnDnsTaskResolve(dns_task_error_);
} else {
DNS_HISTOGRAM("AsyncDNS.FallbackFail", duration);
......@@ -2403,9 +2403,8 @@ void HostResolverImpl::OnDnsTaskResolve(int net_error) {
AbortDnsTasks();
UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", false);
UMA_HISTOGRAM_CUSTOM_ENUMERATION("AsyncDNS.DnsClientDisabledReason",
std::abs(net_error),
GetAllErrorCodesForUma());
UMA_HISTOGRAM_SPARSE_SLOWLY("AsyncDNS.DnsClientDisabledReason",
std::abs(net_error));
}
void HostResolverImpl::SetDnsClient(scoped_ptr<DnsClient> dns_client) {
......
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