EBernhardson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/279064

Change subject: Collect timing information for getting a pooled curl handle
......................................................................

Collect timing information for getting a pooled curl handle

Change-Id: I398b6e622336199d5d6d7c43b0d6a98b02980afd
---
M includes/Elastica/PooledHttp.php
1 file changed, 19 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch 
refs/changes/64/279064/1

diff --git a/includes/Elastica/PooledHttp.php b/includes/Elastica/PooledHttp.php
index 766e611..8ffd02c 100644
--- a/includes/Elastica/PooledHttp.php
+++ b/includes/Elastica/PooledHttp.php
@@ -4,6 +4,7 @@
 
 use Elastica\Transport\Http;
 use MediaWiki\Logger\LoggerFactory;
+use RequestContext;
 
 /**
  * Implements cross-request connection pooling via hhvm's built in
@@ -66,7 +67,10 @@
                        // up to curl.namedPools.$pool.connGetTimeout ms, 
defaulting
                        // to 5000. If the timeout is reached hhvm will raise a 
fatal
                        // error.
+                       $start = microtime( true );
                        $ch = curl_init_pooled( $pool );
+                       $this->reportTiming( microtime( true ) - $start );
+
                        if ( $ch === null ) {
                                LoggerFactory::getInstance( 'CirrusSearch' 
)->warning(
                                        "Elastic connection pool cannot init: 
Unknown pool {pool}. Did you configure curl.namedPools?",
@@ -81,4 +85,19 @@
 
                return $ch;
        }
+
+       /**
+        * @param float $tookS The number of seconds taken to get the pooled 
handle
+        */
+       protected function reportTiming( $tookS ) {
+               // Should this in some way collect stats about requests that 
take longer than normal,
+               // or just allow standard p95 or p99 to collect them? With 
thousands of requests per
+               // second i wonder if a couple servers having issues with their 
pools will by lost in
+               // the noise. Another option could be recording per-server 
stats and including gethostname()
+               // in the key?
+               RequestContext::getMain()->getStats()->timing(
+                       'CirrusSearch.connectionPool.initMs',
+                       intval( 1000 * $tookS )
+               );
+       }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/279064
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I398b6e622336199d5d6d7c43b0d6a98b02980afd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to