Bug 1720610 - Remove expiring unique site origins per loaded tabs telemetry r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D120036
This commit is contained in:
Barret Rennie 2021-07-19 22:25:56 +00:00
Родитель 0abc2b6d04
Коммит c161ad3836
5 изменённых файлов: 0 добавлений и 391 удалений

Просмотреть файл

@ -19,7 +19,6 @@ const { XPCOMUtils } = ChromeUtils.import(
XPCOMUtils.defineLazyModuleGetters(this, {
AppConstants: "resource://gre/modules/AppConstants.jsm",
ClientID: "resource://gre/modules/ClientID.jsm",
BrowserTelemetryUtils: "resource://gre/modules/BrowserTelemetryUtils.jsm",
CustomizableUI: "resource:///modules/CustomizableUI.jsm",
PageActions: "resource:///modules/PageActions.jsm",
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
@ -250,22 +249,6 @@ let URICountListener = {
this._restoredURIsMap.set(browser, uri.spec);
},
onStateChange(browser, webProgress, request, stateFlags, status) {
if (
!webProgress.isTopLevel ||
!(stateFlags & Ci.nsIWebProgressListener.STATE_STOP) ||
!(stateFlags & Ci.nsIWebProgressListener.STATE_IS_WINDOW)
) {
return;
}
if (!(request instanceof Ci.nsIChannel) || !this.isHttpURI(request.URI)) {
return;
}
BrowserUsageTelemetry._recordSiteOriginsPerLoadedTabs();
},
onLocationChange(browser, webProgress, request, uri, flags) {
if (
!(flags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT) &&
@ -444,7 +427,6 @@ let BrowserUsageTelemetry = {
init() {
this._lastRecordTabCount = 0;
this._lastRecordLoadedTabCount = 0;
this._lastRecordSiteOriginsPerLoadedTabs = 0;
this._setupAfterRestore();
this._inited = true;
@ -1286,70 +1268,6 @@ let BrowserUsageTelemetry = {
);
},
/**
* Record telemetry about the ratio of number of site origins per number of
* loaded tabs.
*
* This will only record the telemetry if it has been five minutes since the
* last recording.
*/
_recordSiteOriginsPerLoadedTabs() {
const currentTime = Date.now();
if (
currentTime >
this._lastRecordSiteOriginsPerLoadedTabs + MINIMUM_TAB_COUNT_INTERVAL_MS
) {
this._lastRecordSiteOriginsPerLoadedTabs = currentTime;
// If this is the first load, we discard it because it is likely just the
// browser opening for the first time.
if (this._lastRecordSiteOriginsPerLoadedTabs === 0) {
return;
}
const { loadedTabCount } = getOpenTabsAndWinsCounts();
const siteOrigins = BrowserTelemetryUtils.computeSiteOriginCount(
Services.wm.getEnumerator("navigator:browser"),
false
);
const histogramId = this._getSiteOriginHistogram(loadedTabCount);
// Telemetry doesn't support float values.
Services.telemetry
.getHistogramById(histogramId)
.add(Math.trunc((100 * siteOrigins) / loadedTabCount));
}
},
_siteOriginHistogramIds: [
[1, 1, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_1"],
[2, 4, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_2_4"],
[5, 9, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_5_9"],
[10, 14, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_10_14"],
[15, 19, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_15_19"],
[20, 24, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_20_24"],
[25, 29, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_25_29"],
[31, 34, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_30_34"],
[35, 39, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_35_39"],
[40, 44, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_40_44"],
[45, 49, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_45_49"],
],
/**
* Return the appropriate histogram ID for the given loaded tab count.
*
* Unique site origin telemetry is split across several histograms so that it
* can approximate a unique site origin vs loaded tab count curve.
*
* @param {number} [loadedTabCount] The number of loaded tabs.
*/
_getSiteOriginHistogram(loadedTabCount) {
for (const [min, max, histogramId] of this._siteOriginHistogramIds) {
if (min <= loadedTabCount && loadedTabCount <= max) {
return histogramId;
}
}
return "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_50_PLUS";
},
/**
* Record the number of content processes.
*/

Просмотреть файл

@ -61,9 +61,6 @@ skip-if = verify && debug
[browser_UsageTelemetry_toolbars.js]
[browser_UsageTelemetry_uniqueOriginsVisitedInPast24Hours.js]
[browser_UsageTelemetry_content_aboutRestartRequired.js]
[browser_UsageTelemetry_numberOfSiteOriginsPerTabs.js]
support-files =
multiple_iframes.html
[browser_Telemetry_numberOfSiteOrigins.js]
support-files =
contain_iframe.html

Просмотреть файл

@ -1,145 +0,0 @@
"use strict";
const TEST_ROOT = getRootDirectory(gTestPath).replace(
"chrome://mochitests/content",
"http://mochi.test:8888"
);
function assertHistograms(histograms, expected, message) {
for (let i = 0; i < histograms.length; i++) {
const [name, histogram] = histograms[i];
const actual = histogram.snapshot().values;
const expectedValues = i < expected.length ? expected[i] : {};
Assert.deepEqual(expectedValues, actual, `${name} - ${message}`);
}
}
async function loadAndWaitForStop(tab, uri) {
BrowserUsageTelemetry._lastRecordSiteOriginsPerLoadedTabs = 0;
await Promise.all([
BrowserTestUtils.loadURI(tab.linkedBrowser, uri),
BrowserTestUtils.browserStopped(tab.linkedBrowser, uri),
]);
// Yield the event loop after the document loads to wait for the telemetry
// publish in the Fission case.
await new Promise(resolve => executeSoon(resolve));
await new Promise(resolve => executeSoon(resolve));
}
async function openNewForegroundTab(uri) {
BrowserUsageTelemetry._lastRecordSiteOriginsPerLoadedTabs = 0;
const tab = await BrowserTestUtils.openNewForegroundTab({
gBrowser,
url: uri,
waitForStateStop: true,
});
// Yield the event loop after the document loads to wait for the telemetry
// publish in the Fission case.
await new Promise(resolve => executeSoon(resolve));
return tab;
}
add_task(async function test_siteOriginsPerLoadedTabsHistogram() {
const histograms = BrowserUsageTelemetry._siteOriginHistogramIds.map(
([, , name]) => [name, TelemetryTestUtils.getAndClearHistogram(name)]
);
assertHistograms(histograms, [], "initial");
dump("*** *** load example.com (1)\n");
await loadAndWaitForStop(gBrowser.selectedTab, "http://example.com/");
// We have one origin open in one tab. (100 * 1 / 1)
assertHistograms(
histograms,
[
{ 75: 0, 88: 1, 103: 0 }, // 1 loaded tab.
],
"navigate to https://example.com"
);
let tabs = [await openNewForegroundTab("http://example.com/")];
// We have one origin open in two tabs. (100 * 1 / 2)
assertHistograms(
histograms,
[
{ 75: 0, 88: 1, 103: 0 }, // 1 loaded tab.
{ 40: 0, 47: 1, 55: 0 }, // 2 <= N < 5 loaded tabs.
],
"opening a new tab containing to https://example.com"
);
// Open three new tabs
tabs.push(
await openNewForegroundTab("http://example.com/"),
await openNewForegroundTab("http://example.com/"),
await openNewForegroundTab("http://example.com/")
);
// We have one origin open in five tabs. (100 * 1 / 5)
assertHistograms(
histograms,
[
{ 75: 0, 88: 1, 103: 0 }, // 1 loaded tab.
{ 21: 0, 25: 1, 29: 1, 47: 1, 55: 0 }, // 2 <= N < 5 loaded tabs.
{ 15: 0, 18: 1, 21: 0 }, // 5 <= N < 10 loaded tabs.
],
"open a three new tabs containing https://example.com"
);
for (const tab of tabs) {
BrowserTestUtils.removeTab(tab);
}
tabs = [];
await loadAndWaitForStop(
gBrowser.selectedTab,
`${TEST_ROOT}/multiple_iframes.html`
);
// We have 10 origins open in 1 tab (100 * 10 / 1)
assertHistograms(
histograms,
[
{ 75: 0, 88: 1, 907: 1, 1059: 0 }, // 1 loaded tab.
{ 21: 0, 25: 1, 29: 1, 47: 1, 55: 0 }, // 2 <= N < 5 loaded tabs.
{ 15: 0, 18: 1, 21: 0 }, // 5 <= N < 10 loaded tabs.
],
"navigate to a new tab containing multiple origins"
);
tabs.push(await openNewForegroundTab(`${TEST_ROOT}/multiple_iframes.html`));
// We have 10 origins open in 2 tabs (100 * 10 / 2)
assertHistograms(
histograms,
[
{ 75: 0, 88: 1, 907: 1, 1059: 0 }, // 1 loaded tab.
{ 21: 0, 25: 1, 29: 1, 47: 1, 487: 1, 569: 0 }, // 2 <= N < 5 loaded tabs.
{ 15: 0, 18: 1, 21: 0 }, // 5 <= N < 10 loaded tabs.
],
"navigate to a new tab containing multiple origins"
);
tabs.push(await openNewForegroundTab(`${TEST_ROOT}/multiple_iframes.html`));
// We have 10 origins open in 3 tabs (100 * 10 / 3)
assertHistograms(
histograms,
[
{ 75: 0, 88: 1, 907: 1, 1059: 0 }, // 1 loaded tab.
{ 21: 0, 25: 1, 29: 1, 47: 1, 306: 1, 487: 1, 569: 0 }, // 2 <= N < 5 loaded tabs.
{ 15: 0, 18: 1, 21: 0 }, // 5 <= N < 10 loaded tabs.
],
"navigate to a new tab containing multiple origins"
);
for (const tab of tabs) {
BrowserTestUtils.removeTab(tab);
}
});

Просмотреть файл

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<iframe src="http://example.com"></iframe>
<iframe src="http://example.org/"></iframe>
<iframe src="http://example.net/"></iframe>
<iframe src="http://example.tw/"></iframe>
<iframe src="http://example.in/"></iframe>
<iframe src="http://example.cn/"></iframe>
<iframe src="http://example.co.jp/"></iframe>
<iframe src="http://example.fi/"></iframe>
<iframe src="http://example.lk/"></iframe>
</body>
</html>

Просмотреть файл

@ -7635,150 +7635,6 @@
"alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"],
"releaseChannelCollection": "opt-out"
},
"FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_1": {
"record_in_processes": ["main"],
"products": ["firefox"],
"expires_in_version": "93",
"kind": "exponential",
"high": 5000,
"n_buckets": 50,
"description": "When a document is loaded, if the user has exactly one loaded tab, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection",
"bug_numbers": [1655138],
"alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"],
"releaseChannelCollection": "opt-out"
},
"FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_2_4": {
"record_in_processes": ["main"],
"products": ["firefox"],
"expires_in_version": "93",
"kind": "exponential",
"high": 5000,
"n_buckets": 50,
"description": "When a document is loaded, if the user has a number of loaded tabs in the range 2 <= N <= 4, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection",
"bug_numbers": [1655138],
"alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"],
"releaseChannelCollection": "opt-out"
},
"FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_5_9": {
"record_in_processes": ["main"],
"products": ["firefox"],
"expires_in_version": "93",
"kind": "exponential",
"high": 5000,
"n_buckets": 50,
"description": "When a document is loaded, if the user has a number of loaded tabs in the range 5 <= N <= 9, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection",
"bug_numbers": [1655138],
"alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"],
"releaseChannelCollection": "opt-out"
},
"FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_10_14": {
"record_in_processes": ["main"],
"products": ["firefox"],
"expires_in_version": "93",
"kind": "exponential",
"high": 5000,
"n_buckets": 50,
"description": "When a document is loaded, if the user has a number of loaded tabs in the range 10 <= N <= 14, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection",
"bug_numbers": [1655138],
"alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"],
"releaseChannelCollection": "opt-out"
},
"FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_15_19": {
"record_in_processes": ["main"],
"products": ["firefox"],
"expires_in_version": "93",
"kind": "exponential",
"high": 5000,
"n_buckets": 50,
"description": "When a document is loaded, if the user has a number of loaded tabs in the range 15 <= N <= 19, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection",
"bug_numbers": [1655138],
"alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"],
"releaseChannelCollection": "opt-out"
},
"FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_20_24": {
"record_in_processes": ["main"],
"products": ["firefox"],
"expires_in_version": "93",
"kind": "exponential",
"high": 5000,
"n_buckets": 50,
"description": "When a document is loaded, if the user has a number of loaded tabs in the range 20 <= N <= 24, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection",
"bug_numbers": [1655138],
"alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"],
"releaseChannelCollection": "opt-out"
},
"FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_25_29": {
"record_in_processes": ["main"],
"products": ["firefox"],
"expires_in_version": "93",
"kind": "exponential",
"high": 5000,
"n_buckets": 50,
"description": "When a document is loaded, if the user has a number of loaded tabs in the range 25 <= N <= 29, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection",
"bug_numbers": [1655138],
"alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"],
"releaseChannelCollection": "opt-out"
},
"FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_30_34": {
"record_in_processes": ["main"],
"products": ["firefox"],
"expires_in_version": "93",
"kind": "exponential",
"high": 5000,
"n_buckets": 50,
"description": "When a document is loaded, if the user has a number of loaded tabs in the range 30 <= N <= 34, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection",
"bug_numbers": [1655138],
"alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"],
"releaseChannelCollection": "opt-out"
},
"FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_35_39": {
"record_in_processes": ["main"],
"products": ["firefox"],
"expires_in_version": "93",
"kind": "exponential",
"high": 5000,
"n_buckets": 50,
"description": "When a document is loaded, if the user has a number of loaded tabs in the range 35 <= N <= 39, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection",
"bug_numbers": [1655138],
"alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"],
"releaseChannelCollection": "opt-out"
},
"FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_40_44": {
"record_in_processes": ["main"],
"products": ["firefox"],
"expires_in_version": "93",
"kind": "exponential",
"high": 5000,
"n_buckets": 50,
"description": "When a document is loaded, if the user has a number of loaded tabs in the range 40 <= N <= 44, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection",
"bug_numbers": [1655138],
"alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"],
"releaseChannelCollection": "opt-out"
},
"FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_45_49": {
"record_in_processes": ["main"],
"products": ["firefox"],
"expires_in_version": "93",
"kind": "exponential",
"high": 5000,
"n_buckets": 50,
"description": "When a document is loaded, if the user has a number of loaded tabs in the range 45 <= N <= 49, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection",
"bug_numbers": [1655138],
"alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"],
"releaseChannelCollection": "opt-out"
},
"FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_50_PLUS": {
"record_in_processes": ["main"],
"products": ["firefox"],
"expires_in_version": "93",
"kind": "exponential",
"high": 5000,
"n_buckets": 50,
"description": "When a document is loaded, if the user has 50 or more loaded tabs, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection",
"bug_numbers": [1655138],
"alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"],
"releaseChannelCollection": "opt-out"
},
"FX_TAB_SWITCH_REQUEST_TAB_WARMING_STATE": {
"record_in_processes": ["main"],
"products": ["firefox"],