Commit 305ab900 authored by csharrison's avatar csharrison Committed by Commit bot

Log aggregated abort metrics when histograms are uploaded

This patch adds a method on NetworkMetricsProvider that logs aggregate ABORT
metrics on the NetworkMetricsProvider::ProvideGeneralMetrics callback. This
gives finer grained abort statistics.

BUG=557430

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

Cr-Commit-Position: refs/heads/master@{#381780}
parent 061ea9c8
...@@ -10,11 +10,14 @@ ...@@ -10,11 +10,14 @@
#include <vector> #include <vector>
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/sparse_histogram.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/task_runner_util.h" #include "base/task_runner_util.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "net/base/net_errors.h"
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "components/metrics/net/wifi_access_point_info_provider_chromeos.h" #include "components/metrics/net/wifi_access_point_info_provider_chromeos.h"
...@@ -22,12 +25,13 @@ ...@@ -22,12 +25,13 @@
namespace metrics { namespace metrics {
NetworkMetricsProvider::NetworkMetricsProvider( NetworkMetricsProvider::NetworkMetricsProvider(base::TaskRunner* io_task_runner)
base::TaskRunner* io_task_runner)
: io_task_runner_(io_task_runner), : io_task_runner_(io_task_runner),
connection_type_is_ambiguous_(false), connection_type_is_ambiguous_(false),
wifi_phy_layer_protocol_is_ambiguous_(false), wifi_phy_layer_protocol_is_ambiguous_(false),
wifi_phy_layer_protocol_(net::WIFI_PHY_LAYER_PROTOCOL_UNKNOWN), wifi_phy_layer_protocol_(net::WIFI_PHY_LAYER_PROTOCOL_UNKNOWN),
total_aborts_(0),
total_codes_(0),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
net::NetworkChangeNotifier::AddConnectionTypeObserver(this); net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
connection_type_ = net::NetworkChangeNotifier::GetConnectionType(); connection_type_ = net::NetworkChangeNotifier::GetConnectionType();
...@@ -43,6 +47,7 @@ void NetworkMetricsProvider::ProvideGeneralMetrics( ...@@ -43,6 +47,7 @@ void NetworkMetricsProvider::ProvideGeneralMetrics(
// ProvideGeneralMetrics is called on the main thread, at the time a metrics // ProvideGeneralMetrics is called on the main thread, at the time a metrics
// record is being finalized. // record is being finalized.
net::NetworkChangeNotifier::FinalizingMetricsLogRecord(); net::NetworkChangeNotifier::FinalizingMetricsLogRecord();
LogAggregatedMetrics();
} }
void NetworkMetricsProvider::ProvideSystemProfileMetrics( void NetworkMetricsProvider::ProvideSystemProfileMetrics(
...@@ -240,4 +245,21 @@ void NetworkMetricsProvider::WriteWifiAccessPointProto( ...@@ -240,4 +245,21 @@ void NetworkMetricsProvider::WriteWifiAccessPointProto(
} }
} }
void NetworkMetricsProvider::LogAggregatedMetrics() {
base::HistogramBase* error_codes = base::SparseHistogram::FactoryGet(
"Net.ErrorCodesForMainFrame3",
base::HistogramBase::kUmaTargetedHistogramFlag);
scoped_ptr<base::HistogramSamples> samples = error_codes->SnapshotSamples();
base::HistogramBase::Count new_aborts =
samples->GetCount(-net::ERR_ABORTED) - total_aborts_;
base::HistogramBase::Count new_codes = samples->TotalCount() - total_codes_;
if (new_codes > 0) {
UMA_HISTOGRAM_COUNTS("Net.ErrAborted.CountPerUpload", new_aborts);
UMA_HISTOGRAM_PERCENTAGE("Net.ErrAborted.ProportionPerUpload",
(100 * new_aborts) / new_codes);
total_codes_ += new_codes;
total_aborts_ += new_aborts;
}
}
} // namespace metrics } // namespace metrics
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/metrics/histogram_base.h"
#include "components/metrics/metrics_provider.h" #include "components/metrics/metrics_provider.h"
#include "components/metrics/net/wifi_access_point_info_provider.h" #include "components/metrics/net/wifi_access_point_info_provider.h"
#include "components/metrics/proto/system_profile.pb.h" #include "components/metrics/proto/system_profile.pb.h"
...@@ -52,6 +53,9 @@ class NetworkMetricsProvider ...@@ -52,6 +53,9 @@ class NetworkMetricsProvider
const WifiAccessPointInfoProvider::WifiAccessPointInfo& info, const WifiAccessPointInfoProvider::WifiAccessPointInfo& info,
SystemProfileProto::Network* network_proto); SystemProfileProto::Network* network_proto);
// Logs metrics that are functions of other metrics being uploaded.
void LogAggregatedMetrics();
// Task runner used for blocking file I/O. // Task runner used for blocking file I/O.
base::TaskRunner* io_task_runner_; base::TaskRunner* io_task_runner_;
...@@ -69,6 +73,11 @@ class NetworkMetricsProvider ...@@ -69,6 +73,11 @@ class NetworkMetricsProvider
// Helper object for retrieving connected wifi access point information. // Helper object for retrieving connected wifi access point information.
scoped_ptr<WifiAccessPointInfoProvider> wifi_access_point_info_provider_; scoped_ptr<WifiAccessPointInfoProvider> wifi_access_point_info_provider_;
// These metrics track histogram totals for the Net.ErrorCodesForMainFrame3
// histogram. They are used to compute deltas at upload time.
base::HistogramBase::Count total_aborts_;
base::HistogramBase::Count total_codes_;
base::WeakPtrFactory<NetworkMetricsProvider> weak_ptr_factory_; base::WeakPtrFactory<NetworkMetricsProvider> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(NetworkMetricsProvider); DISALLOW_COPY_AND_ASSIGN(NetworkMetricsProvider);
......
...@@ -25078,6 +25078,22 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. ...@@ -25078,6 +25078,22 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary> </summary>
</histogram> </histogram>
<histogram name="Net.ErrAborted.CountPerUpload" units="aborts">
<owner>csharrison@chromium.org</owner>
<summary>
The count of the ABORTED bucket in Net.ErrorCodesForMainFrame3 at the time
histograms are being uploaded.
</summary>
</histogram>
<histogram name="Net.ErrAborted.ProportionPerUpload" units="%">
<owner>csharrison@chromium.org</owner>
<summary>
The bucket proportion of the ABORTED bucket in Net.ErrorCodesForMainFrame3
at the time histograms are being uploaded.
</summary>
</histogram>
<histogram name="Net.ErrAborted.ReceivedBytes" units="bytes"> <histogram name="Net.ErrAborted.ReceivedBytes" units="bytes">
<owner>csharrison@chromium.org</owner> <owner>csharrison@chromium.org</owner>
<summary> <summary>
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