From 39c4d09727499ceeae02abfd18fc79c580c0e249 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 25 Mar 2016 12:13:34 -0700 Subject: [PATCH] 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 --- includes/api/ApiMain.php | 6 ++++++ 1 file changed, 6 insertions(+) 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 ); + } } } -- 2.20.1