Bug 1198517 - [Metrics] Histogram support for user-timing-based metrics. r=janx

This commit is contained in:
Russ Nicoletti 2015-09-08 13:11:46 -07:00
parent 347e6f2bc9
commit 83129e4926
4 changed files with 190 additions and 30 deletions

View File

@ -765,9 +765,25 @@ let performanceEntriesWatcher = {
_fronts: new Map(),
_appLaunchName: null,
_appLaunchStartTime: null,
_supported: [
'contentInteractive',
'navigationInteractive',
'navigationLoaded',
'visuallyLoaded',
'fullyLoaded',
'mediaEnumerated',
'scanEnd'
],
init(client) {
this._client = client;
let setting = 'devtools.telemetry.supported_performance_marks';
let defaultValue = this._supported.join(',');
SettingsListener.observe(setting, defaultValue, supported => {
let value = supported || defaultValue;
this._supported = value.split(',');
});
},
trackTarget(target) {
@ -783,38 +799,56 @@ let performanceEntriesWatcher = {
front.start();
front.on('entry', detail => {
if (detail.type === 'mark') {
let name = detail.name;
let epoch = detail.epoch;
let CHARS_UNTIL_APP_NAME = 7; // '@app://'
// FIXME There is a potential race condition that can result
// in some performance entries being disregarded. See bug 1189942.
if (name.indexOf('appLaunch') != -1) {
let appStartPos = name.indexOf('@app') + CHARS_UNTIL_APP_NAME;
let length = (name.indexOf('.') - appStartPos);
this._appLaunchName = name.substr(appStartPos, length);
this._appLaunchStartTime = epoch;
} else {
let origin = detail.origin;
origin = origin.substr(0, origin.indexOf('.'));
if (this._appLaunchName === origin) {
let time = epoch - this._appLaunchStartTime;
let eventName = 'app-startup-time-' + name;
// Events based on performance marks are for telemetry only, they are
// not displayed in the HUD front end.
target._logHistogram({name: eventName, value: time});
memoryWatcher.front(target).residentUnique().then(value => {
eventName = 'app-memory-' + name;
target._logHistogram({name: eventName, value: value});
}, err => {
console.error(err);
});
}
}
// Only process performance marks.
if (detail.type !== 'mark') {
return;
}
let name = detail.name;
let epoch = detail.epoch;
// FIXME There is a potential race condition that can result
// in some performance entries being disregarded. See bug 1189942.
//
// If this is an "app launch" mark, record the app that was
// launched and the epoch of when it was launched.
if (name.indexOf('appLaunch') !== -1) {
let CHARS_UNTIL_APP_NAME = 7; // '@app://'
let startPos = name.indexOf('@app') + CHARS_UNTIL_APP_NAME;
let endPos = name.indexOf('.');
this._appLaunchName = name.slice(startPos, endPos);
this._appLaunchStartTime = epoch;
return;
}
// Only process supported performance marks
if (this._supported.indexOf(name) === -1) {
return;
}
let origin = detail.origin;
origin = origin.slice(0, origin.indexOf('.'));
// Continue if the performance mark corresponds to the app
// for which we have recorded app launch information.
if (this._appLaunchName !== origin) {
return;
}
let time = epoch - this._appLaunchStartTime;
let eventName = 'app_startup_time_' + name;
// Events based on performance marks are for telemetry only, they are
// not displayed in the HUD front end.
target._logHistogram({name: eventName, value: time});
memoryWatcher.front(target).residentUnique().then(value => {
eventName = 'app_memory_' + name;
target._logHistogram({name: eventName, value: value});
}, err => {
console.error(err);
});
});
},

View File

@ -573,6 +573,10 @@ let settingsToObserve = {
'devtools.remote.wifi.visible': {
resetToPref: true
},
'devtools.telemetry.supported_performance_marks': {
resetToPref: true
},
'dom.mozApps.use_reviewer_certs': false,
'dom.mozApps.signed_apps_installable_from': 'https://marketplace.firefox.com',
'dom.presentation.discovery.enabled': false,

View File

@ -900,6 +900,9 @@ pref("devtools.gcli.imgurUploadURL", "https://api.imgur.com/3/image");
// GCLI commands directory
pref("devtools.commands.dir", "");
// Allows setting the performance marks for which telemetry metrics will be recorded.
pref("devtools.telemetry.supported_performance_marks", "contentInteractive,navigationInteractive,navigationLoaded,visuallyLoaded,fullyLoaded,mediaEnumerated,scanEnd");
// view source
pref("view_source.syntax_highlight", true);
pref("view_source.wrap_long_lines", false);

View File

@ -8890,6 +8890,125 @@
"keyed": "true",
"description": "Number of warnings, keyed by appName."
},
"DEVTOOLS_HUD_APP_STARTUP_TIME_CONTENTINTERACTIVE": {
"expires_in_version": "never",
"kind": "linear",
"keyed": "true",
"description": "The duration in ms between application launch and the 'contentInteractive' performance mark, keyed by appName.",
"high": "2000",
"n_buckets": 10
},
"DEVTOOLS_HUD_APP_STARTUP_TIME_NAVIGATIONINTERACTIVE": {
"expires_in_version": "never",
"kind": "linear",
"keyed": "true",
"description": "The duration in ms between application launch and the 'navigationInteractive' performance mark, keyed by appName.",
"high": "3000",
"n_buckets": 10
},
"DEVTOOLS_HUD_APP_STARTUP_TIME_NAVIGATIONLOADED": {
"expires_in_version": "never",
"kind": "linear",
"keyed": "true",
"description": "The duration in ms between application launch and the 'navigationLoaded' performance mark, keyed by appName.",
"high": "4000",
"n_buckets": 10
},
"DEVTOOLS_HUD_APP_STARTUP_TIME_VISUALLYLOADED": {
"expires_in_version": "never",
"kind": "linear",
"keyed": "true",
"description": "The duration in ms between application launch and the 'visuallyLoaded' performance mark, keyed by appName.",
"high": "5000",
"n_buckets": 10
},
"DEVTOOLS_HUD_APP_STARTUP_TIME_MEDIAENUMERATED": {
"expires_in_version": "never",
"kind": "linear",
"keyed": "true",
"description": "The duration in ms between application launch and the 'mediaEnumerated' performance mark, keyed by appName.",
"high": "5000",
"n_buckets": 10
},
"DEVTOOLS_HUD_APP_STARTUP_TIME_FULLYLOADED": {
"expires_in_version": "never",
"kind": "linear",
"keyed": "true",
"description": "The duration in ms between application launch and the 'fullyLoaded' performance mark, keyed by appName.",
"high": "30000",
"n_buckets": 30
},
"DEVTOOLS_HUD_APP_STARTUP_TIME_SCANEND": {
"expires_in_version": "never",
"kind": "linear",
"keyed": "true",
"description": "The duration in ms between application launch and the 'scanEnd' performance mark, keyed by appName.",
"high": "30000",
"n_buckets": 30
},
"DEVTOOLS_HUD_APP_MEMORY_CONTENTINTERACTIVE": {
"expires_in_version": "never",
"kind": "linear",
"keyed": "true",
"description": "The USS memory consumed by an application at the time of the 'contentInteractive' performance mark, keyed by appName.",
"low": "2000000",
"high": "3000000",
"n_buckets": 10
},
"DEVTOOLS_HUD_APP_MEMORY_NAVIGATIONINTERACTIVE": {
"expires_in_version": "never",
"kind": "linear",
"keyed": "true",
"description": "The USS memory consumed by an application at the time of the 'navigationInteractive' performance mark, keyed by appName.",
"low": "2000000",
"high": "3000000",
"n_buckets": 10
},
"DEVTOOLS_HUD_APP_MEMORY_NAVIGATIONLOADED": {
"expires_in_version": "never",
"kind": "linear",
"keyed": "true",
"description": "The USS memory consumed by an application at the time of the 'navigationLoaded' performance mark, keyed by appName.",
"low": "2000000",
"high": "3000000",
"n_buckets": 10
},
"DEVTOOLS_HUD_APP_MEMORY_VISUALLYLOADED": {
"expires_in_version": "never",
"kind": "linear",
"keyed": "true",
"description": "The USS memory consumed by an application at the time of the 'visuallyLoaded' performance mark, keyed by appName.",
"low": "2000000",
"high": "3000000",
"n_buckets": 10
},
"DEVTOOLS_HUD_APP_MEMORY_MEDIAENUMERATED": {
"expires_in_version": "never",
"kind": "linear",
"keyed": "true",
"description": "The USS memory consumed by an application at the time of the 'mediaEnumerated' performance mark, keyed by appName.",
"low": "2000000",
"high": "3000000",
"n_buckets": 10
},
"DEVTOOLS_HUD_APP_MEMORY_FULLYLOADED": {
"expires_in_version": "never",
"kind": "linear",
"keyed": "true",
"description": "The USS memory consumed by an application at the time of the 'fullyLoaded' performance mark, keyed by appName.",
"low": "2000000",
"high": "4000000",
"n_buckets": 20
},
"DEVTOOLS_HUD_APP_MEMORY_SCANEND": {
"expires_in_version": "never",
"kind": "linear",
"keyed": "true",
"description": "The USS memory consumed by an application at the time of the 'scanEnd' performance mark, keyed by appName.",
"low": "2000000",
"high": "4000000",
"n_buckets": 20
},
"GRAPHICS_SANITY_TEST_REASON": {
"alert_emails": ["danderson@mozilla.com"],
"expires_in_version": "43",