EBernhardson has uploaded a new change for review.

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

Change subject: Switch A/B test logs over to a more easily analysable format
......................................................................

Switch A/B test logs over to a more easily analysable format

Bug: T108869
Change-Id: Ie2e1e581edf54021e0eb122d7a8842187127e3e5
---
M includes/ElasticsearchIntermediary.php
1 file changed, 39 insertions(+), 26 deletions(-)


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

diff --git a/includes/ElasticsearchIntermediary.php 
b/includes/ElasticsearchIntermediary.php
index 7daf5b4..a93e9ad 100644
--- a/includes/ElasticsearchIntermediary.php
+++ b/includes/ElasticsearchIntermediary.php
@@ -115,37 +115,50 @@
                        return;
                }
                $ut = UserTesting::getInstance();
-               $tests = array();
-               foreach ( $ut->getActiveTestNames() as $test ) {
-                       $tests[$test] = $ut->getBucket( $test );
-               }
-               if ( !$tests ) {
+               if ( !$ut->getActiveTestNames() ) {
                        return;
                }
-               $report = array(
-                       'wiki' => wfWikiId(),
-                       'tests' => $tests,
-                       'queries' => array(),
-                       'hits' => 0,
-                       'source' => self::getExecutionContext(),
-                       'ip' => $wgRequest->getIP(),
-                       'xff' => $wgRequest->getHeader( 'X-Forwarded-For' ),
-                       'userAgent' => $wgRequest->getHeader( 'User-Agent' ),
-               );
-
+               $queries = array();
+               $parameters = array( 'index' => array(), 'queryType' => array() 
);
+               $elasticTook = 0;
+               $hits = 0;
                foreach ( self::$logContexts as $context ) {
-                       $report['hits'] += isset( $context['hitsTotal'] ) ? 
$context['hitsTotal'] : 0;
-                       $report['queries'][] = array(
-                               'queryType' => isset( $context['queryType'] ) ? 
$context['queryType'] : '',
-                               'query' => isset( $context['query'] ) ? 
$context['query'] : '',
-                               'suggest' => isset( $context['suggestion'] ) ? 
$context['suggestion'] : '',
-                               'elasticTook' => isset( $context['elasticTook'] 
) ? $context['elasticTook'] : '',
-                               'index' => isset( $context['index'] ) ? 
$context['index'] : '',
-                       );
+                       $hits += isset( $context['hitsTotal'] ) ? 
$context['hitsTotal'] : 0;
+                       $queries[] = $context['query'];
+                       if ( isset( $context['elasticTookMs'] ) ) {
+                               $elasticTook += $context['elasticTookMs'];
+                       }
+                       if ( isset( $context['index'] ) ) {
+                               $parameters['index'][] = $context['index'];
+                       }
+                       if ( isset( $context['queryType'] ) ) {
+                               $parameters['queryType'][] = 
$context['queryType'];
+                       }
+
+               }
+               foreach ( array( 'index', 'queryType' ) as $key ) {
+                       $parameters[$key] = array_unique( $parameters[$key] );
                }
 
-               $message = FormatJson::encode( $report );
-               LoggerFactory::getInstance( 'CirrusSearchUserTesting' )->debug( 
$message );
+               $message = array(
+                       wfWikiId(),
+                       '',
+                       FormatJson::encode( $queries ),
+                       $hits,
+                       self::getExecutionContext(),
+                       $elasticTook,
+                       $wgRequest->getIP(),
+                       preg_replace( "/[\t\"']/", "", $wgRequest->getHeader( 
'User-Agent') ),
+                       FormatJson::encode( $parameters ),
+               );
+
+               $tests = array();
+               $logger = LoggerFactory::getInstance( 'CirrusSearchUserTesting' 
);
+               foreach ( $ut->getActiveTestNames() as $test ) {
+                       $bucket = $ut->getBucket( $test );
+                       $message[1] = "{$test}-{$bucket}";
+                       $logger->debug( implode( "\t", $message ) );
+               }
                self::$logContexts = null;
        }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie2e1e581edf54021e0eb122d7a8842187127e3e5
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