public static function onArticleViewAfterParser(Article $article, ParserOutput $parserOutput) { global $wgCityId, $wgDBname; // we collect production data from Oasis only /* $app = F::app(); if ( !$app->checkSkin( 'oasis', $app->wg->Skin ) || $app->wg->DevelEnvironment || $app->wg->StagingEnvironment ) { return true; } */ if (class_exists('WScribeClient')) { try { $title = $article->getTitle(); $fields = array('wikiId' => intval($wgCityId), 'databaseName' => $wgDBname, 'articleId' => $title->getArticleID(), 'namespaceId' => $title->getNamespace(), 'articleTitle' => $title->getText(), 'parserTime' => $parserOutput->getPerformanceStats('time'), 'wikitextSize' => $parserOutput->getPerformanceStats('wikitextSize'), 'htmlSize' => $parserOutput->getPerformanceStats('htmlSize'), 'expFuncCount' => $parserOutput->getPerformanceStats('expFuncCount'), 'nodeCount' => $parserOutput->getPerformanceStats('nodeCount'), 'postExpandSize' => $parserOutput->getPerformanceStats('postExpandSize'), 'tempArgSize' => $parserOutput->getPerformanceStats('tempArgSize')); $data = json_encode($fields); WScribeClient::singleton(self::SCRIBE_KEY)->send($data); } catch (TException $e) { Wikia::log(__METHOD__, 'scribeClient exception', $e->getMessage()); } } // Logging parser activity for monitoring // wiki and article info are sent to logstash anyways so no need to repeat them here WikiaLogger::instance()->info("Parser execution", ['parser-time' => round($parserOutput->getPerformanceStats('time') * 1000), 'node-count' => (int) $parserOutput->getPerformanceStats('nodeCount'), 'wikitext-size' => (int) $parserOutput->getPerformanceStats('wikitextSize'), 'skin-name' => RequestContext::getMain()->getSkin()->getSkinName()]); return true; }
/** * Hook handler. Sets a "size category" attribute based on the article that is displayed * * @param Article $article * @param ParserOutput $parserOutput * @return bool true (hook handler) */ public static function onArticleViewAddParserOutput(Article $article, ParserOutput $parserOutput) { $wikitextSize = $parserOutput->getPerformanceStats('wikitextSize'); $htmlSize = $parserOutput->getPerformanceStats('htmlSize'); $expFuncCount = $parserOutput->getPerformanceStats('expFuncCount'); $nodeCount = $parserOutput->getPerformanceStats('nodeCount'); if (!is_numeric($wikitextSize) || !is_numeric($htmlSize) || !is_numeric($expFuncCount) || !is_numeric($nodeCount)) { return true; } if ($wikitextSize < 3000 && $htmlSize < 5000 && $expFuncCount == 0 && $nodeCount < 100) { $sizeCategory = self::SIZE_CATEGORY_SIMPLE; } elseif ($wikitextSize < 30000 && $htmlSize < 50000 && $expFuncCount <= 4 && $nodeCount < 3000) { $sizeCategory = self::SIZE_CATEGORY_AVERAGE; } else { $sizeCategory = self::SIZE_CATEGORY_COMPLEX; } Transaction::setAttribute(Transaction::PARAM_SIZE_CATEGORY, $sizeCategory); return true; }