EBernhardson has uploaded a new change for review.

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

Change subject: Log an executor id in ElasticsearchIntermediary
......................................................................

Log an executor id in ElasticsearchIntermediary

Auto forwarding did you mean (I7ed79942) will mean that queries with
no results and requested via the web will be repeated. We need a way
to tie together these two queries in the log files and treat them as
one for the stats.

Patch updates CirrusSearchRequests to include an executor id. This
value is unique to a particular web request or job run and will allow
us to group together queries that happened together. When running
analytics against these logs only the last minute perhaps of
executor ids need to be remembered.

Bug: T105202
Change-Id: I7997c17f9d73d6070c7416b5de21f8b1fe8a5cc4
(cherry picked from commit e53c8ea477e24d55bd1fe879221a1e649fe9db81)
---
M includes/ElasticsearchIntermediary.php
1 file changed, 20 insertions(+), 1 deletion(-)


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

diff --git a/includes/ElasticsearchIntermediary.php 
b/includes/ElasticsearchIntermediary.php
index 0f7385c..dce6040 100644
--- a/includes/ElasticsearchIntermediary.php
+++ b/includes/ElasticsearchIntermediary.php
@@ -51,6 +51,11 @@
        private $searchMetrics = array();
 
        /**
+        * @var string Id identifying this php execution
+        */
+       static private $executionId;
+
+       /**
         * Constructor.
         *
         * @param User|null $user user for which this search is being 
performed.  Attached to slow request logs.  Note that
@@ -63,6 +68,20 @@
        protected function __construct( User $user = null, $slowSeconds ) {
                $this->user = $user;
                $this->slowMillis = round( 1000 * $slowSeconds );
+       }
+
+       /**
+        * Identifies a specific execution of php.  That might be one web
+        * request, or multiple jobs run in the same executor. An execution id
+        * is valid over a brief timespan, perhaps a minute or two for some 
jobs.
+        *
+        * @return integer unique identifier
+        */
+       private static function getExecutionId() {
+               if ( self::$executionId === null ) {
+                       self::$executionId = mt_rand();
+               }
+               return self::$executionId;
        }
 
        /**
@@ -203,7 +222,7 @@
                } else {
                        $source = 'web';
                }
-               $logMessage .= ". Requested via $source.";
+               $logMessage .= ". Requested via $source by executor " . 
self::getExecutionId();
 
                // Now log and clear our state.
                LoggerFactory::getInstance( 'CirrusSearchRequests' )->debug( 
$logMessage );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7997c17f9d73d6070c7416b5de21f8b1fe8a5cc4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: wmf/1.26wmf15
Gerrit-Owner: EBernhardson <[email protected]>

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

Reply via email to