mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Linter
synced 2024-11-23 23:44:17 +00:00
Merge "Record totals in categories in statsd"
This commit is contained in:
commit
69fd50c811
|
@ -64,7 +64,8 @@
|
|||
},
|
||||
"LinterSubmitterWhitelist": {
|
||||
"127.0.0.1": true
|
||||
}
|
||||
},
|
||||
"LinterStatsdSampleFactor": false
|
||||
},
|
||||
"manifest_version": 1
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
namespace MediaWiki\Linter;
|
||||
|
||||
use Job;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Title;
|
||||
|
||||
class RecordLintJob extends Job {
|
||||
|
@ -62,7 +63,34 @@ class RecordLintJob extends Job {
|
|||
}
|
||||
|
||||
$lintDb->setForPage( $toSet );
|
||||
$this->updateStats( $lintDb );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send stats to statsd
|
||||
*
|
||||
* @param Database $lintDb
|
||||
*/
|
||||
protected function updateStats( Database $lintDb ) {
|
||||
global $wgLinterStatsdSampleFactor;
|
||||
|
||||
if ( $wgLinterStatsdSampleFactor === false ) {
|
||||
// Not enabled at all
|
||||
return;
|
||||
} elseif ( mt_rand( 1, $wgLinterStatsdSampleFactor ) != 1 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$totals = $lintDb->getTotals();
|
||||
|
||||
$stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
|
||||
foreach ( $totals as $name => $count ) {
|
||||
$stats->gauge( "linter.category.$name", $count );
|
||||
}
|
||||
|
||||
$stats->gauge( "linter.totals", array_sum( $totals ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue