* Added stats to job insert and pop.
* Formalised live patch for UDP stats aggregation, adding $wgAggregateStatsID.
* Added UserGetLanguageObject hook to change the language used in $wgLang
* (bug 14645) When $wgMiserMode is on, expensive special pages are styled
differently (italicized by default) on Special:SpecialPages
+* Added $wgAggregateStatsID, which allows UDP stats to be aggregated over
+ several wikis.
=== Bug fixes in 1.18 ===
* (bug 23119) WikiError class and subclasses are now marked as deprecated
*/
$wgStatsMethod = 'cache';
+/**
+ * When $wgStatsMethod is 'udp', setting this to a string allows statistics to
+ * be aggregated over more than one wiki. The string will be used in place of
+ * the DB name in outgoing UDP packets. If this is set to false, the DB name
+ * will be used.
+ */
+$wgAggregateStatsID = false;
+
/** Whereas to count the number of time an article is viewed.
* Does not work if pages are cached (for example with squid).
*/
/**
* Increment a statistics counter
*/
-function wfIncrStats( $key ) {
+function wfIncrStats( $key, $count = 1 ) {
global $wgStatsMethod;
+ $count = intval( $count );
+
if( $wgStatsMethod == 'udp' ) {
- global $wgUDPProfilerHost, $wgUDPProfilerPort, $wgDBname;
+ global $wgUDPProfilerHost, $wgUDPProfilerPort, $wgDBname, $wgAggregateStatsID;
static $socket;
+
+ $id = $wgAggregateStatsID !== false ? $wgAggregateStatsID : $wgDBname;
+
if ( !$socket ) {
$socket = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP );
- $statline = "stats/{$wgDBname} - 1 1 1 1 1 -total\n";
+ $statline = "stats/{$id} - {$count} 1 1 1 1 -total\n";
socket_sendto(
$socket,
$statline,
$wgUDPProfilerPort
);
}
- $statline = "stats/{$wgDBname} - 1 1 1 1 1 {$key}\n";
+ $statline = "stats/{$id} - {$count} 1 1 1 1 {$key}\n";
wfSuppressWarnings();
socket_sendto(
$socket,
} elseif( $wgStatsMethod == 'cache' ) {
global $wgMemc;
$key = wfMemcKey( 'stats', $key );
- if ( is_null( $wgMemc->incr( $key ) ) ) {
- $wgMemc->add( $key, 1 );
+ if ( is_null( $wgMemc->incr( $key, $count ) ) ) {
+ $wgMemc->add( $key, $count );
}
} else {
// Disabled
return false;
}
+ wfIncrStats( 'job-pop' );
$namespace = $row->job_namespace;
$dbkey = $row->job_title;
$title = Title::makeTitleSafe( $namespace, $dbkey );
// If execution got to here, there's a row in $row that has been deleted from the database
// by this thread. Hence the concurrent pop was successful.
+ wfIncrStats( 'job-pop' );
$namespace = $row->job_namespace;
$dbkey = $row->job_title;
$title = Title::makeTitleSafe( $namespace, $dbkey );
}
}
if ( $rows ) {
+ wfIncrStats( 'job-insert', count( $rows ) );
$dbw->begin();
$dbw->insert( 'job', $rows, __METHOD__, 'IGNORE' );
$dbw->commit();
return;
}
}
+ wfIncrStats( 'job-insert' );
return $dbw->insert( 'job', $fields, __METHOD__ );
}