mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-25 08:36:21 +00:00
Merge "Remve usage of RequestContext::getStats()"
This commit is contained in:
commit
a03e234372
|
@ -218,8 +218,17 @@ class ScribuntoHooks {
|
||||||
static $stats;
|
static $stats;
|
||||||
|
|
||||||
if ( !$stats ) {
|
if ( !$stats ) {
|
||||||
|
// check, if MediaWikiServices exists and has a StatsdDataFactory service for
|
||||||
|
// backward-compatibility with MediaWiki 1.25+
|
||||||
|
if (
|
||||||
|
class_exists( 'MediaWiki\\MediaWikiServices' ) &&
|
||||||
|
\MediaWiki\MediaWikiServices::getInstance()->hasService( 'StatsdDataFactory' )
|
||||||
|
) {
|
||||||
|
$stats = \MediaWiki\MediaWikiServices::getInstance()->getStatsdDataFactory();
|
||||||
|
} else {
|
||||||
$stats = RequestContext::getMain()->getStats();
|
$stats = RequestContext::getMain()->getStats();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$metricKey = sprintf( 'scribunto.traces.%s__%s__%s', wfWikiId(), $moduleName, $functionName );
|
$metricKey = sprintf( 'scribunto.traces.%s__%s__%s', wfWikiId(), $moduleName, $functionName );
|
||||||
$stats->timing( $metricKey, $timing );
|
$stats->timing( $metricKey, $timing );
|
||||||
|
|
Loading…
Reference in a new issue