*/
use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
use Wikimedia\Timestamp\TimestampException;
/**
$runTime = microtime( true ) - $t;
$this->logRequest( $runTime );
if ( $this->mModule->isWriteMode() && $this->getRequest()->wasPosted() ) {
- $this->getStats()->timing(
+ MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
'api.' . $this->mModule->getModuleName() . '.executeTiming', 1000 * $runTime
);
}
* @file
*/
use Liuggio\StatsdClient\Factory\StatsdDataFactory;
+use MediaWiki\MediaWikiServices;
/**
* The simplest way of implementing IContextSource is to hold a RequestContext as a
* @return StatsdDataFactory
*/
public function getStats() {
- return $this->getContext()->getStats();
+ return MediaWikiServices::getInstance()->getStatsdDataFactory();
}
/**
*
* @file
*/
+use MediaWiki\MediaWikiServices;
use Wikimedia\Assert\Assert;
/**
}
protected function doUpdateContextStats() {
- $stats = RequestContext::getMain()->getStats();
+ $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
foreach ( [ 'edits', 'articles', 'pages', 'users', 'images' ] as $type ) {
$delta = $this->$type;
if ( $delta !== 0 ) {
* @file
* @ingroup DifferenceEngine
*/
+use MediaWiki\MediaWikiServices;
/** @deprecated use class constant instead */
define( 'MW_DIFF_VERSION', '1.11a' );
$result = $this->textDiff( $otext, $ntext );
$time = intval( ( microtime( true ) - $time ) * 1000 );
- $this->getStats()->timing( 'diff_time', $time );
+ MediaWikiServices::getInstance()->getStatsdDataFactory()->timing( 'diff_time', $time );
// Log requests slower than 99th percentile
if ( $time > 100 && $this->mOldPage && $this->mNewPage ) {
wfDebugLog( 'diff',
*
* Represents files in a repository.
*/
+use MediaWiki\MediaWikiServices;
/**
* Base code for files.
$this->fsFile = $this->repo->getLocalReference( $this->getPath() );
$statTiming = microtime( true ) - $starttime;
- RequestContext::getMain()->getStats()->timing(
+ MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
'media.thumbnail.generate.fetchoriginal', 1000 * $statTiming );
if ( !$this->fsFile ) {
public function generateAndSaveThumb( $tmpFile, $transformParams, $flags ) {
global $wgIgnoreImageErrors;
- $stats = RequestContext::getMain()->getStats();
+ $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
$handler = $this->getHandler();
// this object exists
$tmpFile->bind( $this );
- RequestContext::getMain()->getStats()->timing(
+ MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
'media.thumbnail.generate.bucket', 1000 * $buckettime );
return true;
* @defgroup JobQueue JobQueue
* @author Aaron Schulz
*/
+use MediaWiki\MediaWikiServices;
/**
* Class to handle enqueueing and running of background jobs
public static function incrStats( $key, $type, $delta = 1 ) {
static $stats;
if ( !$stats ) {
- $stats = RequestContext::getMain()->getStats();
+ $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
}
$stats->updateCount( "jobqueue.{$key}.all", $delta );
$stats->updateCount( "jobqueue.{$key}.{$type}", $delta );
*
* @file
*/
+use MediaWiki\MediaWikiServices;
/**
* Class for viewing MediaWiki article and history.
$useParserCache = $this->mPage->shouldCheckParserCache( $parserOptions, $oldid );
wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
if ( $user->getStubThreshold() ) {
- $this->getContext()->getStats()->increment( 'pcache_miss_stub' );
+ MediaWikiServices::getInstance()->getStatsdDataFactory()->increment( 'pcache_miss_stub' );
}
$this->showRedirectedFromHeader();
* @file
* @ingroup Profiler
*/
+use MediaWiki\MediaWikiServices;
/**
* ProfilerOutput class that flushes profiling data to the profiling
*/
public function log( array $stats ) {
$prefix = isset( $this->params['prefix'] ) ? $this->params['prefix'] : '';
- $contextStats = $this->collector->getContext()->getStats();
+ $contextStats = MediaWikiServices::getInstance()->getStatsdDataFactory();
foreach ( $stats as $stat ) {
$key = "{$prefix}.{$stat['name']}";
return self::applyFilter( $filter, $data );
}
- $stats = RequestContext::getMain()->getStats();
+ $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
$cache = ObjectCache::getLocalServerInstance( CACHE_ANYTHING );
$key = $cache->makeGlobalKey(
*/
final protected function buildContent( ResourceLoaderContext $context ) {
$rl = $context->getResourceLoader();
- $stats = RequestContext::getMain()->getStats();
+ $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
$statStart = microtime( true );
// Only include properties that are relevant to this context (e.g. only=scripts)
*/
use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
define( 'MW_NO_OUTPUT_COMPRESSION', 1 );
require __DIR__ . '/includes/WebStart.php';
$streamtime = microtime( true ) - $starttime;
if ( $status->isOK() ) {
- RequestContext::getMain()->getStats()->timing( 'media.thumbnail.stream', $streamtime );
+ MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
+ 'media.thumbnail.stream', $streamtime
+ );
} else {
wfThumbError( 500, 'Could not stream the file', null, [ 'file' => $thumbName,
'path' => $thumbPath, 'error' => $status->getWikiText( false, false, 'en' ) ] );