+ /**
+ * @return array
+ */
+ private function getMaxLag() {
+ $dbLag = MediaWikiServices::getInstance()->getDBLoadBalancer()->getMaxLag();
+ $lagInfo = [
+ 'host' => $dbLag[0],
+ 'lag' => $dbLag[1],
+ 'type' => 'db'
+ ];
+
+ $jobQueueLagFactor = $this->getConfig()->get( 'JobQueueIncludeInMaxLagFactor' );
+ if ( $jobQueueLagFactor ) {
+ // Turn total number of jobs into seconds by using the configured value
+ $totalJobs = array_sum( JobQueueGroup::singleton()->getQueueSizes() );
+ $jobQueueLag = $totalJobs / (float)$jobQueueLagFactor;
+ if ( $jobQueueLag > $lagInfo['lag'] ) {
+ $lagInfo = [
+ 'host' => wfHostname(), // XXX: Is there a better value that could be used?
+ 'lag' => $jobQueueLag,
+ 'type' => 'jobqueue',
+ 'jobs' => $totalJobs,
+ ];
+ }
+ }
+
+ return $lagInfo;
+ }
+