From 008a5d7e2c4320f072694588c7e617a94b84a380 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 29 Apr 2016 15:47:11 -0700 Subject: [PATCH] Fix executeTiming statsd metrics Nothing was being sent out before. Change-Id: I5d3c681337fc49bd3026781c1bcddf0f2d8e6b8a --- includes/api/ApiMain.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 07642c48ed..4fa197ff84 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -134,7 +134,9 @@ class ApiMain extends ApiBase { private $mModuleMgr, $mResult, $mErrorFormatter, $mContinuationManager; private $mAction; private $mEnableWrite; - private $mInternalMode, $mSquidMaxage, $mModule; + private $mInternalMode, $mSquidMaxage; + /** @var ApiBase */ + private $mModule; private $mCacheMode = 'private'; private $mCacheControl = []; @@ -397,13 +399,7 @@ 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 ); - } } } @@ -433,8 +429,12 @@ class ApiMain extends ApiBase { $isError = false; try { $this->executeAction(); - $this->logRequest( microtime( true ) - $t ); - + $runTime = microtime( true ) - $t; + $this->logRequest( $runTime ); + if ( $this->mModule->isWriteMode() && $this->getRequest()->wasPosted() ) { + $this->getStats()->timing( + 'api.' . $this->getModuleName() . '.executeTiming', 1000 * $runTime ); + } } catch ( Exception $e ) { $this->handleException( $e ); $this->logRequest( microtime( true ) - $t, $e ); -- 2.20.1