mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-23 22:13:34 +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.core.utils.parsing",
|
||||
"mediawiki.jqueryMsg",
|
||||
"mediawiki.String",
|
||||
"jquery.textSelection",
|
||||
"mediawiki.api",
|
||||
"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 {Object} data Additional data describing the event, encoded as an object
|
||||
*/
|
||||
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 ) {
|
||||
// HACK: track serializeForCache duration here, because there's no event for that
|
||||
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.trackTiming( 'behavior.firstTransaction', {
|
||||
duration: ve.now() - this.timings.surfaceReady,
|
||||
mode: this.target.surface.getMode()
|
||||
duration: ve.now() - this.timings.surfaceReady
|
||||
} );
|
||||
};
|
||||
|
||||
|
@ -125,7 +130,7 @@ ve.init.mw.ArticleTargetEvents.prototype.onSaveComplete = function ( data ) {
|
|||
* @param {string} code Error code
|
||||
*/
|
||||
ve.init.mw.ArticleTargetEvents.prototype.trackSaveError = function ( code ) {
|
||||
// Maps mwtiming types to mwedit types
|
||||
// Maps error codes to mwedit types
|
||||
var typeMap = {
|
||||
badtoken: 'userBadToken',
|
||||
assertanonfailed: 'userNewUser',
|
||||
|
@ -149,7 +154,6 @@ ve.init.mw.ArticleTargetEvents.prototype.trackSaveError = function ( code ) {
|
|||
}
|
||||
this.trackTiming( key, {
|
||||
duration: ve.now() - this.timings.saveInitiated,
|
||||
retries: this.timings.saveRetries,
|
||||
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 ) {
|
||||
var feature = topic.split( '.' )[ 1 ];
|
||||
|
||||
|
@ -352,7 +337,6 @@
|
|||
// mw.eventLog.dispatch.
|
||||
mw.loader.using( 'ext.eventLogging' ).done( function () {
|
||||
ve.trackSubscribe( 'mwedit.', mwEditHandler );
|
||||
ve.trackSubscribe( 'mwtiming.', mwTimingHandler );
|
||||
} );
|
||||
}
|
||||
|
||||
|
|
|
@ -327,15 +327,10 @@
|
|||
}
|
||||
}
|
||||
if ( !apiPromise ) {
|
||||
apiPromise = apiXhr.then( function ( response, jqxhr ) {
|
||||
apiPromise = apiXhr.then( function ( response ) {
|
||||
ve.track( 'trace.apiLoad.exit', { mode: 'visual' } );
|
||||
ve.track( 'mwtiming.performance.system.apiLoad', {
|
||||
bytes: require( 'mediawiki.String' ).byteLength( jqxhr.responseText ),
|
||||
duration: ve.now() - start,
|
||||
cacheHit: /hit/i.test( jqxhr.getResponseHeader( 'X-Cache' ) ),
|
||||
targetName: options.targetName,
|
||||
mode: 'visual'
|
||||
} );
|
||||
mw.track( 'timing.ve.' + options.targetName + '.performance.system.apiLoad',
|
||||
ve.now() - start );
|
||||
if ( response.visualeditor ) {
|
||||
response.visualeditor.switched = switched;
|
||||
response.visualeditor.fromEditedState = fromEditedState;
|
||||
|
@ -403,12 +398,8 @@
|
|||
var restbasePromise = restbaseXhr.then(
|
||||
function ( response, status, jqxhr ) {
|
||||
ve.track( 'trace.restbaseLoad.exit', { mode: 'visual' } );
|
||||
ve.track( 'mwtiming.performance.system.restbaseLoad', {
|
||||
bytes: require( 'mediawiki.String' ).byteLength( jqxhr.responseText ),
|
||||
duration: ve.now() - start,
|
||||
targetName: options.targetName,
|
||||
mode: 'visual'
|
||||
} );
|
||||
mw.track( 'timing.ve.' + options.targetName + '.performance.system.restbaseLoad',
|
||||
ve.now() - start );
|
||||
return [ response, jqxhr.getResponseHeader( 'etag' ) ];
|
||||
},
|
||||
function ( xhr, code, _ ) {
|
||||
|
|
Loading…
Reference in a new issue