From 175e60edaf4bcffe83030a561d000fbf60144f9b Mon Sep 17 00:00:00 2001 From: ecotg Date: Tue, 24 Mar 2015 20:36:44 -0600 Subject: [PATCH] Strip X-Parsoid Performance Headers from Visual Editor Stripped out X-Parsoid Performance Headers, previously used to gather and forward Parsoid's performance information, from ApiVisualEditor.php, ve.init.mw.Target.js and ve.init.mw.TargetLoader.js. Change I936ada7b1 strips out the corresponding X-Parsoid Performance Headers from Parsoid. Parsoid's current performance instrumentation is achieved using Graphite and txstatsd. Change-Id: I57d6f866a7d8287a5115e6236b0fb25bc4d0eabd --- ApiVisualEditor.php | 15 ++++++--------- modules/ve-mw/init/ve.init.mw.Target.js | 6 ++---- modules/ve-mw/init/ve.init.mw.TargetLoader.js | 3 +-- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/ApiVisualEditor.php b/ApiVisualEditor.php index e2cb85cd1c..3ce4056416 100644 --- a/ApiVisualEditor.php +++ b/ApiVisualEditor.php @@ -90,19 +90,16 @@ class ApiVisualEditor extends ApiBase { } $response = $this->serviceClient->run( $request ); if ( $response['code'] === 200 && $response['error'] === "" ) { - // Pass thru performance data from Parsoid to the client, unless the response was - // served directly from Varnish, in which case discard the value of the XPP header - // and use it to declare the cache hit instead. + // If response was served directly from Varnish, use the response + // (RP) header to declare the cache hit and pass the data to the client. $headers = $response['headers']; - $xpp = null; + $rp = null; if ( isset( $headers['x-cache'] ) && strpos( $headers['x-cache'], 'hit' ) !== false ) { - $xpp = 'cached-response=true'; - } elseif ( isset( $headers['x-parsoid-performance'] ) ) { - $xpp = $headers['x-parsoid-performance']; + $rp = 'cached-response=true'; } - if ( $xpp !== null ) { + if ( $rp !== null ) { $resp = $this->getRequest()->response(); - $resp->header( 'X-Parsoid-Performance: ' . $xpp ); + $resp->header( 'X-Cache: ' . $rp ); } } elseif ( $response['error'] !== '' ) { $this->dieUsage( 'parsoidserver-http-error: ' . $response['error'], $response['error'] ); diff --git a/modules/ve-mw/init/ve.init.mw.Target.js b/modules/ve-mw/init/ve.init.mw.Target.js index 07a67e469b..7700e287f1 100644 --- a/modules/ve-mw/init/ve.init.mw.Target.js +++ b/modules/ve-mw/init/ve.init.mw.Target.js @@ -1095,8 +1095,7 @@ ve.init.mw.Target.prototype.tryWithPreparedCacheKey = function ( doc, options, e function ( response, jqxhr ) { var eventData = { bytes: $.byteLength( jqxhr.responseText ), - duration: ve.now() - start, - parsoid: jqxhr.getResponseHeader( 'X-Parsoid-Performance' ) + duration: ve.now() - start }; // Log data about the request if eventName was set @@ -1112,8 +1111,7 @@ ve.init.mw.Target.prototype.tryWithPreparedCacheKey = function ( doc, options, e if ( errorObject && errorObject.xhr ) { eventData = { bytes: $.byteLength( errorObject.xhr.responseText ), - duration: ve.now() - start, - parsoid: errorObject.xhr.getResponseHeader( 'X-Parsoid-Performance' ) + duration: ve.now() - start }; if ( eventName ) { diff --git a/modules/ve-mw/init/ve.init.mw.TargetLoader.js b/modules/ve-mw/init/ve.init.mw.TargetLoader.js index 99f3dc30a3..6d2a8fb01b 100644 --- a/modules/ve-mw/init/ve.init.mw.TargetLoader.js +++ b/modules/ve-mw/init/ve.init.mw.TargetLoader.js @@ -121,8 +121,7 @@ ve.track( 'mwtiming.performance.system.apiLoad', { bytes: $.byteLength( jqxhr.responseText ), duration: ve.now() - start, - cacheHit: /hit/i.test( jqxhr.getResponseHeader( 'X-Cache' ) ), - parsoid: jqxhr.getResponseHeader( 'X-Parsoid-Performance' ) + cacheHit: /hit/i.test( jqxhr.getResponseHeader( 'X-Cache' ) ) } ); return data; } );