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

Unified Diff: chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer.cc

Issue 2642553002: Adding UMA for data reduction proxy page load size/savings (Closed)
Patch Set: Created 3 years, 11 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
Index: chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer.cc
diff --git a/chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer.cc b/chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer.cc
index 50e1cdbaa1ab92012a541d2ad8bb643fb5b59d33..e9ada2b4192d41b5473397e8c8d81a75222ef60e 100644
--- a/chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer.cc
+++ b/chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer.cc
@@ -6,6 +6,7 @@
#include <string>
+#include "base/metrics/histogram_macros.h"
#include "base/optional.h"
#include "base/time/time.h"
#include "chrome/browser/loader/chrome_navigation_data.h"
@@ -78,7 +79,12 @@ const char kHistogramParseDurationSuffix[] = "ParseTiming.ParseDuration";
} // namespace internal
DataReductionProxyMetricsObserver::DataReductionProxyMetricsObserver()
- : browser_context_(nullptr) {}
+ : browser_context_(nullptr),
+ num_data_reduction_proxy_requests_(0),
+ num_network_requests_(0),
+ original_network_bytes_(0),
+ network_bytes_proxied_(0),
+ network_bytes_(0) {}
DataReductionProxyMetricsObserver::~DataReductionProxyMetricsObserver() {}
@@ -128,6 +134,7 @@ page_load_metrics::PageLoadMetricsObserver::ObservePolicy
DataReductionProxyMetricsObserver::OnHidden(
const page_load_metrics::PageLoadTiming& timing,
const page_load_metrics::PageLoadExtraInfo& info) {
+ RecordPageSizeUMA();
SendPingback(timing, info);
return STOP_OBSERVING;
}
@@ -140,6 +147,7 @@ DataReductionProxyMetricsObserver::FlushMetricsOnAppEnterBackground(
// app is about to be backgrounded, as part of the Activity.onPause()
// flow. After this method is invoked, Chrome may be killed without further
// notification, so we send a pingback with data collected up to this point.
+ RecordPageSizeUMA();
SendPingback(timing, info);
return STOP_OBSERVING;
}
@@ -147,9 +155,112 @@ DataReductionProxyMetricsObserver::FlushMetricsOnAppEnterBackground(
void DataReductionProxyMetricsObserver::OnComplete(
const page_load_metrics::PageLoadTiming& timing,
const page_load_metrics::PageLoadExtraInfo& info) {
+ RecordPageSizeUMA();
SendPingback(timing, info);
}
+void DataReductionProxyMetricsObserver::RecordPageSizeUMA() {
tbansal1 2017/01/18 22:35:19 const method?
RyanSturm 2017/01/18 22:57:49 Done.
+ if (num_network_requests_ == 0) {
+ return;
tbansal1 2017/01/18 22:35:19 Why return? It might be useful to know if there ar
RyanSturm 2017/01/18 22:57:49 This is happens when the main page request uses DR
+ }
+
+ // The percent of requests that went through the data reduction proxy.
+ int percent_proxied_requests =
+ 100 * num_data_reduction_proxy_requests_ / num_network_requests_;
tbansal1 2017/01/18 22:35:19 do we need parenthesis here? to get around the amb
RyanSturm 2017/01/18 22:57:49 No, but I'll add it for you.
+ UMA_HISTOGRAM_PERCENTAGE(
+ std::string(internal::kHistogramDataReductionProxyPrefix)
+ .append("Experimental.Requests.Network.PercentProxied"),
+ percent_proxied_requests);
+
+ // The percent of bytes that went through the data reduction proxy.
+ if (network_bytes_ > 0) {
+ int percent_network_bytes_proxied =
+ 100 * network_bytes_proxied_ / network_bytes_;
+ UMA_HISTOGRAM_PERCENTAGE(
+ std::string(internal::kHistogramDataReductionProxyPrefix)
+ .append("Experimental.Bytes.Network.PercentProxied"),
+ percent_network_bytes_proxied);
+ }
+
+ // If the data reduction proxy caused savings, record the compression ratio;
+ // otherwise, record the inflation ratio.
+ if (original_network_bytes_ > 0 && original_network_bytes_ > network_bytes_) {
tbansal1 2017/01/18 22:35:19 s/>/>=/ for the second condition? If the two are e
RyanSturm 2017/01/18 22:57:49 Done.
+ int compression_ratio = 100 * network_bytes_ / original_network_bytes_;
+ UMA_HISTOGRAM_PERCENTAGE(
+ std::string(internal::kHistogramDataReductionProxyPrefix)
+ .append("Experimental.Bytes.Network.CompressionRatio"),
tbansal1 2017/01/18 22:35:19 Should we record savings percent because that's wh
RyanSturm 2017/01/18 22:57:49 I'd prefer compression ratio because it shows when
+ compression_ratio);
+ } else if (network_bytes_ > 0) {
tbansal1 2017/01/18 22:35:19 Can network_bytes_ be 0 when num_network_requests_
RyanSturm 2017/01/18 22:57:49 I assume so. This is body bytes, and I believe bod
+ int inflation_ratio = 100 * original_network_bytes_ / network_bytes_;
tbansal1 2017/01/18 22:35:19 This histogram is difficult to parse. eg., if orig
RyanSturm 2017/01/18 22:57:49 Done.
+ UMA_HISTOGRAM_PERCENTAGE(
+ std::string(internal::kHistogramDataReductionProxyPrefix)
+ .append("Experimental.Bytes.Network.InflationRatio"),
+ inflation_ratio);
+ }
+
+ // Record the number of network requests seen.
+ UMA_HISTOGRAM_COUNTS_10000(
+ std::string(internal::kHistogramDataReductionProxyPrefix)
+ .append("Experimental.Requests.Network"),
+ num_network_requests_);
+
+ // Record the number of requests that used data reduction proxy.
+ UMA_HISTOGRAM_COUNTS_10000(
+ std::string(internal::kHistogramDataReductionProxyPrefix)
+ .append("Experimental.Requests.Network.Proxied"),
+ num_data_reduction_proxy_requests_);
+
+ // Record the number of requests that did not use data reduction proxy.
+ UMA_HISTOGRAM_COUNTS_10000(
+ std::string(internal::kHistogramDataReductionProxyPrefix)
+ .append("Experimental.Requests.Network.NonProxied"),
+ num_network_requests_ - num_data_reduction_proxy_requests_);
+
+ // Record the total KB of network bytes.
+ UMA_HISTOGRAM_CUSTOM_COUNTS(
+ std::string(internal::kHistogramDataReductionProxyPrefix)
+ .append("Experimental.Bytes.Network"),
tbansal1 2017/01/18 22:35:19 Use KB or KiloBytes in the histogram name to avoid
RyanSturm 2017/01/18 22:57:49 It's in the units on histograms.xml and I am stand
+ static_cast<int>(network_bytes_) / 1024, 1, 500 * 1024, 50);
+
+ // Record the total amount of bytes that went through the data reduction
+ // proxy.
+ UMA_HISTOGRAM_CUSTOM_COUNTS(
+ std::string(internal::kHistogramDataReductionProxyPrefix)
+ .append("Experimental.Bytes.Network.Proxied"),
+ static_cast<int>(network_bytes_proxied_) / 1024, 1, 500 * 1024, 50);
tbansal1 2017/01/18 22:35:19 Can you add a comment that upper bucket is 500 MB.
RyanSturm 2017/01/18 22:57:49 Done.
+
+ // Record the total amount of bytes that did not go through the data reduction
+ // proxy.
+ UMA_HISTOGRAM_CUSTOM_COUNTS(
+ std::string(internal::kHistogramDataReductionProxyPrefix)
+ .append("Experimental.Bytes.Network.NonProxied"),
+ static_cast<int>(network_bytes_proxied_) / 1024, 1, 500 * 1024, 50);
tbansal1 2017/01/18 22:35:19 s/network_bytes_proxied_/network_bytes_ - network_
RyanSturm 2017/01/18 22:57:49 Done.
+
+ // Record the total KB of network bytes that the user would have seen without
+ // using data reduction proxy.
+ UMA_HISTOGRAM_CUSTOM_COUNTS(
+ std::string(internal::kHistogramDataReductionProxyPrefix)
+ .append("Experimental.Bytes.Network.Original"),
+ static_cast<int>(original_network_bytes_) / 1024, 1, 500 * 1024, 50);
+
+ // Record the savings the user saw by using data reduction proxy. If there was
+ // inflation instead, record that.
+ if (network_bytes_ < original_network_bytes_) {
tbansal1 2017/01/18 22:35:19 s/</<=/
RyanSturm 2017/01/18 22:57:49 Done.
+ UMA_HISTOGRAM_CUSTOM_COUNTS(
+ std::string(internal::kHistogramDataReductionProxyPrefix)
+ .append("Experimental.Bytes.Network.Savings"),
+ static_cast<int>(original_network_bytes_ - network_bytes_) / 1024, 1,
+ 500 * 1024, 50);
+ } else {
+ UMA_HISTOGRAM_CUSTOM_COUNTS(
+ std::string(internal::kHistogramDataReductionProxyPrefix)
+ .append("Experimental.Bytes.Network.Inflation"),
+ static_cast<int>(network_bytes_proxied_ - original_network_bytes_) /
+ 1024,
+ 1, 500 * 1024, 50);
+ }
+}
+
void DataReductionProxyMetricsObserver::SendPingback(
const page_load_metrics::PageLoadTiming& timing,
const page_load_metrics::PageLoadExtraInfo& info) {
@@ -284,6 +395,19 @@ void DataReductionProxyMetricsObserver::OnParseStop(
internal::kHistogramParseBlockedOnScriptLoadSuffix);
}
+void DataReductionProxyMetricsObserver::OnLoadedResource(
+ const page_load_metrics::ExtraRequestInfo& extra_request_info) {
+ if (extra_request_info.was_cached)
+ return;
+ original_network_bytes_ += extra_request_info.original_network_content_length;
+ network_bytes_ += extra_request_info.raw_body_bytes;
+ num_network_requests_++;
+ if (!extra_request_info.data_reduction_proxy_used)
+ return;
+ num_data_reduction_proxy_requests_++;
+ network_bytes_proxied_ += extra_request_info.raw_body_bytes;
+}
+
DataReductionProxyPingbackClient*
DataReductionProxyMetricsObserver::GetPingbackClient() const {
return DataReductionProxyChromeSettingsFactory::GetForBrowserContext(

Powered by Google App Engine
This is Rietveld 408576698