mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 06:24:08 +00:00
Simplify timing tracking code
Peel off some layers, remove some unused computation, remove code from ve.init.mw.trackSubscriber.js (which is to be removed in T332438). Change-Id: I4073b9a2a4b2af06f30e603a9d2a1968203f3b6d
This commit is contained in:
parent
4604c4a79f
commit
1cdb641116
|
@ -384,7 +384,6 @@
|
||||||
"ext.visualEditor.track",
|
"ext.visualEditor.track",
|
||||||
"ext.visualEditor.core.utils.parsing",
|
"ext.visualEditor.core.utils.parsing",
|
||||||
"mediawiki.jqueryMsg",
|
"mediawiki.jqueryMsg",
|
||||||
"mediawiki.String",
|
|
||||||
"jquery.textSelection",
|
"jquery.textSelection",
|
||||||
"mediawiki.api",
|
"mediawiki.api",
|
||||||
"web2017-polyfills",
|
"web2017-polyfills",
|
||||||
|
|
|
@ -46,19 +46,25 @@ ve.init.mw.ArticleTargetEvents.prototype.track = function ( topic, data ) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Target specific ve.track wrapper, focused on mwtiming
|
* Target specific ve.track wrapper, focused on timing
|
||||||
*
|
*
|
||||||
* @param {string} topic Event name
|
* @param {string} topic Event name
|
||||||
* @param {Object} data Additional data describing the event, encoded as an object
|
* @param {Object} data Additional data describing the event, encoded as an object
|
||||||
*/
|
*/
|
||||||
ve.init.mw.ArticleTargetEvents.prototype.trackTiming = function ( topic, data ) {
|
ve.init.mw.ArticleTargetEvents.prototype.trackTiming = function ( topic, data ) {
|
||||||
data.targetName = this.target.constructor.static.trackingName;
|
|
||||||
this.track( 'mwtiming.' + topic, data );
|
|
||||||
|
|
||||||
if ( topic.indexOf( 'performance.system.serializeforcache' ) === 0 ) {
|
if ( topic.indexOf( 'performance.system.serializeforcache' ) === 0 ) {
|
||||||
// HACK: track serializeForCache duration here, because there's no event for that
|
// HACK: track serializeForCache duration here, because there's no event for that
|
||||||
this.timings.serializeForCache = data.duration;
|
this.timings.serializeForCache = data.duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add type for save errors; not in the topic for stupid historical reasons
|
||||||
|
if ( topic === 'performance.user.saveError' ) {
|
||||||
|
topic = topic + '.' + data.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
topic = 'timing.ve.' + this.target.constructor.static.trackingName + '.' + topic;
|
||||||
|
|
||||||
|
mw.track( topic, data.duration );
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,8 +74,7 @@ ve.init.mw.ArticleTargetEvents.prototype.onFirstTransaction = function () {
|
||||||
this.track( 'mwedit.firstChange' );
|
this.track( 'mwedit.firstChange' );
|
||||||
|
|
||||||
this.trackTiming( 'behavior.firstTransaction', {
|
this.trackTiming( 'behavior.firstTransaction', {
|
||||||
duration: ve.now() - this.timings.surfaceReady,
|
duration: ve.now() - this.timings.surfaceReady
|
||||||
mode: this.target.surface.getMode()
|
|
||||||
} );
|
} );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -125,7 +130,7 @@ ve.init.mw.ArticleTargetEvents.prototype.onSaveComplete = function ( data ) {
|
||||||
* @param {string} code Error code
|
* @param {string} code Error code
|
||||||
*/
|
*/
|
||||||
ve.init.mw.ArticleTargetEvents.prototype.trackSaveError = function ( code ) {
|
ve.init.mw.ArticleTargetEvents.prototype.trackSaveError = function ( code ) {
|
||||||
// Maps mwtiming types to mwedit types
|
// Maps error codes to mwedit types
|
||||||
var typeMap = {
|
var typeMap = {
|
||||||
badtoken: 'userBadToken',
|
badtoken: 'userBadToken',
|
||||||
assertanonfailed: 'userNewUser',
|
assertanonfailed: 'userNewUser',
|
||||||
|
@ -149,7 +154,6 @@ ve.init.mw.ArticleTargetEvents.prototype.trackSaveError = function ( code ) {
|
||||||
}
|
}
|
||||||
this.trackTiming( key, {
|
this.trackTiming( key, {
|
||||||
duration: ve.now() - this.timings.saveInitiated,
|
duration: ve.now() - this.timings.saveInitiated,
|
||||||
retries: this.timings.saveRetries,
|
|
||||||
type: code
|
type: code
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
|
@ -274,21 +274,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mwTimingHandler( topic, data ) {
|
|
||||||
// Add type for save errors; not in the topic for stupid historical reasons
|
|
||||||
if ( topic === 'mwtiming.performance.user.saveError' ) {
|
|
||||||
topic = topic + '.' + data.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Map mwtiming.foo --> timing.ve.foo.mobile
|
|
||||||
topic = topic.replace( /^mwtiming/, 'timing.ve.' + data.targetName );
|
|
||||||
if ( trackdebug ) {
|
|
||||||
log( topic, Math.round( data.duration ) + 'ms' );
|
|
||||||
} else {
|
|
||||||
mw.track( topic, data.duration );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function activityHandler( topic, data ) {
|
function activityHandler( topic, data ) {
|
||||||
var feature = topic.split( '.' )[ 1 ];
|
var feature = topic.split( '.' )[ 1 ];
|
||||||
|
|
||||||
|
@ -352,7 +337,6 @@
|
||||||
// mw.eventLog.dispatch.
|
// mw.eventLog.dispatch.
|
||||||
mw.loader.using( 'ext.eventLogging' ).done( function () {
|
mw.loader.using( 'ext.eventLogging' ).done( function () {
|
||||||
ve.trackSubscribe( 'mwedit.', mwEditHandler );
|
ve.trackSubscribe( 'mwedit.', mwEditHandler );
|
||||||
ve.trackSubscribe( 'mwtiming.', mwTimingHandler );
|
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -327,15 +327,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !apiPromise ) {
|
if ( !apiPromise ) {
|
||||||
apiPromise = apiXhr.then( function ( response, jqxhr ) {
|
apiPromise = apiXhr.then( function ( response ) {
|
||||||
ve.track( 'trace.apiLoad.exit', { mode: 'visual' } );
|
ve.track( 'trace.apiLoad.exit', { mode: 'visual' } );
|
||||||
ve.track( 'mwtiming.performance.system.apiLoad', {
|
mw.track( 'timing.ve.' + options.targetName + '.performance.system.apiLoad',
|
||||||
bytes: require( 'mediawiki.String' ).byteLength( jqxhr.responseText ),
|
ve.now() - start );
|
||||||
duration: ve.now() - start,
|
|
||||||
cacheHit: /hit/i.test( jqxhr.getResponseHeader( 'X-Cache' ) ),
|
|
||||||
targetName: options.targetName,
|
|
||||||
mode: 'visual'
|
|
||||||
} );
|
|
||||||
if ( response.visualeditor ) {
|
if ( response.visualeditor ) {
|
||||||
response.visualeditor.switched = switched;
|
response.visualeditor.switched = switched;
|
||||||
response.visualeditor.fromEditedState = fromEditedState;
|
response.visualeditor.fromEditedState = fromEditedState;
|
||||||
|
@ -403,12 +398,8 @@
|
||||||
var restbasePromise = restbaseXhr.then(
|
var restbasePromise = restbaseXhr.then(
|
||||||
function ( response, status, jqxhr ) {
|
function ( response, status, jqxhr ) {
|
||||||
ve.track( 'trace.restbaseLoad.exit', { mode: 'visual' } );
|
ve.track( 'trace.restbaseLoad.exit', { mode: 'visual' } );
|
||||||
ve.track( 'mwtiming.performance.system.restbaseLoad', {
|
mw.track( 'timing.ve.' + options.targetName + '.performance.system.restbaseLoad',
|
||||||
bytes: require( 'mediawiki.String' ).byteLength( jqxhr.responseText ),
|
ve.now() - start );
|
||||||
duration: ve.now() - start,
|
|
||||||
targetName: options.targetName,
|
|
||||||
mode: 'visual'
|
|
||||||
} );
|
|
||||||
return [ response, jqxhr.getResponseHeader( 'etag' ) ];
|
return [ response, jqxhr.getResponseHeader( 'etag' ) ];
|
||||||
},
|
},
|
||||||
function ( xhr, code, _ ) {
|
function ( xhr, code, _ ) {
|
||||||
|
|
Loading…
Reference in a new issue