From: Aaron Schulz Date: Fri, 25 Mar 2016 19:13:34 +0000 (-0700) Subject: Time POST requests to API write modules X-Git-Tag: 1.31.0-rc.0~7468 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/Main?a=commitdiff_plain;h=39c4d09727499ceeae02abfd18fc79c580c0e249;p=lhc%2Fweb%2Fwiklou.git Time POST requests to API write modules This lets us capture some basic endpoint timing data that is lacking now, such as upload API call time. Change-Id: If0627e2d78d82b22ed6bdaaa0fa7fe5f20ef50b1 --- diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 1f1a1e8f84..e3725116d1 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -397,7 +397,13 @@ class ApiMain extends ApiBase { if ( $this->mInternalMode ) { $this->executeAction(); } else { + $start = microtime( true ); $this->executeActionWithErrorHandling(); + if ( $this->isWriteMode() && $this->getRequest()->wasPosted() ) { + $timeMs = 1000 * max( 0, microtime( true ) - $start ); + $this->getStats()->timing( + 'api.' . $this->getModuleName() . '.executeTiming', $timeMs ); + } } }