Send API timing to statsd for all requests, not just writes
authorTim Starling <tstarling@wikimedia.org>
Fri, 20 Jul 2018 06:49:49 +0000 (16:49 +1000)
committerTim Starling <tstarling@wikimedia.org>
Fri, 20 Jul 2018 06:49:49 +0000 (16:49 +1000)
The rate will be about 8k req/s, whereas currently graphite1001
receives about 350k metric updates per second, so we would expect
this to increase statsd load by about 2%.

This would have been very helpful in diagnosing API cluster overload
incidents such as the one on July 11.

Change-Id: I0a248e1bcec05915d98ec735f4cfb9800e64412d

includes/api/ApiMain.php

index b398ecd..84708e7 100644 (file)
@@ -535,11 +535,9 @@ class ApiMain extends ApiBase {
                        $this->executeAction();
                        $runTime = microtime( true ) - $t;
                        $this->logRequest( $runTime );
-                       if ( $this->mModule->isWriteMode() && $this->getRequest()->wasPosted() ) {
-                               MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
-                                       'api.' . $this->mModule->getModuleName() . '.executeTiming', 1000 * $runTime
-                               );
-                       }
+                       MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
+                               'api.' . $this->mModule->getModuleName() . '.executeTiming', 1000 * $runTime
+                       );
                } catch ( Exception $e ) {
                        $this->handleException( $e );
                        $this->logRequest( microtime( true ) - $t, $e );