Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -2071,15 +2071,20 @@ |
2072 | 2072 | /** |
2073 | 2073 | * Increment a statistics counter |
2074 | 2074 | */ |
2075 | | -function wfIncrStats( $key ) { |
| 2075 | +function wfIncrStats( $key, $count = 1 ) { |
2076 | 2076 | global $wgStatsMethod; |
2077 | 2077 | |
| 2078 | + $count = intval( $count ); |
| 2079 | + |
2078 | 2080 | if( $wgStatsMethod == 'udp' ) { |
2079 | | - global $wgUDPProfilerHost, $wgUDPProfilerPort, $wgDBname; |
| 2081 | + global $wgUDPProfilerHost, $wgUDPProfilerPort, $wgDBname, $wgAggregateStatsID; |
2080 | 2082 | static $socket; |
| 2083 | + |
| 2084 | + $id = $wgAggregateStatsID !== false ? $wgAggregateStatsID : $wgDBname; |
| 2085 | + |
2081 | 2086 | if ( !$socket ) { |
2082 | 2087 | $socket = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP ); |
2083 | | - $statline = "stats/{$wgDBname} - 1 1 1 1 1 -total\n"; |
| 2088 | + $statline = "stats/{$id} - {$count} 1 1 1 1 -total\n"; |
2084 | 2089 | socket_sendto( |
2085 | 2090 | $socket, |
2086 | 2091 | $statline, |
— | — | @@ -2089,7 +2094,7 @@ |
2090 | 2095 | $wgUDPProfilerPort |
2091 | 2096 | ); |
2092 | 2097 | } |
2093 | | - $statline = "stats/{$wgDBname} - 1 1 1 1 1 {$key}\n"; |
| 2098 | + $statline = "stats/{$id} - {$count} 1 1 1 1 {$key}\n"; |
2094 | 2099 | wfSuppressWarnings(); |
2095 | 2100 | socket_sendto( |
2096 | 2101 | $socket, |
— | — | @@ -2103,8 +2108,8 @@ |
2104 | 2109 | } elseif( $wgStatsMethod == 'cache' ) { |
2105 | 2110 | global $wgMemc; |
2106 | 2111 | $key = wfMemcKey( 'stats', $key ); |
2107 | | - if ( is_null( $wgMemc->incr( $key ) ) ) { |
2108 | | - $wgMemc->add( $key, 1 ); |
| 2112 | + if ( is_null( $wgMemc->incr( $key, $count ) ) ) { |
| 2113 | + $wgMemc->add( $key, $count ); |
2109 | 2114 | } |
2110 | 2115 | } else { |
2111 | 2116 | // Disabled |
Index: trunk/phase3/includes/job/JobQueue.php |
— | — | @@ -74,6 +74,7 @@ |
75 | 75 | return false; |
76 | 76 | } |
77 | 77 | |
| 78 | + wfIncrStats( 'job-pop' ); |
78 | 79 | $namespace = $row->job_namespace; |
79 | 80 | $dbkey = $row->job_title; |
80 | 81 | $title = Title::makeTitleSafe( $namespace, $dbkey ); |
— | — | @@ -163,6 +164,7 @@ |
164 | 165 | |
165 | 166 | // If execution got to here, there's a row in $row that has been deleted from the database |
166 | 167 | // by this thread. Hence the concurrent pop was successful. |
| 168 | + wfIncrStats( 'job-pop' ); |
167 | 169 | $namespace = $row->job_namespace; |
168 | 170 | $dbkey = $row->job_title; |
169 | 171 | $title = Title::makeTitleSafe( $namespace, $dbkey ); |
— | — | @@ -238,6 +240,7 @@ |
239 | 241 | } |
240 | 242 | } |
241 | 243 | if ( $rows ) { |
| 244 | + wfIncrStats( 'job-insert', count( $rows ) ); |
242 | 245 | $dbw->begin(); |
243 | 246 | $dbw->insert( 'job', $rows, __METHOD__, 'IGNORE' ); |
244 | 247 | $dbw->commit(); |
— | — | @@ -280,6 +283,7 @@ |
281 | 284 | return; |
282 | 285 | } |
283 | 286 | } |
| 287 | + wfIncrStats( 'job-insert' ); |
284 | 288 | return $dbw->insert( 'job', $fields, __METHOD__ ); |
285 | 289 | } |
286 | 290 | |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -3940,6 +3940,14 @@ |
3941 | 3941 | */ |
3942 | 3942 | $wgStatsMethod = 'cache'; |
3943 | 3943 | |
| 3944 | +/** |
| 3945 | + * When $wgStatsMethod is 'udp', setting this to a string allows statistics to |
| 3946 | + * be aggregated over more than one wiki. The string will be used in place of |
| 3947 | + * the DB name in outgoing UDP packets. If this is set to false, the DB name |
| 3948 | + * will be used. |
| 3949 | + */ |
| 3950 | +$wgAggregateStatsID = false; |
| 3951 | + |
3944 | 3952 | /** Whereas to count the number of time an article is viewed. |
3945 | 3953 | * Does not work if pages are cached (for example with squid). |
3946 | 3954 | */ |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -94,6 +94,8 @@ |
95 | 95 | * Added UserGetLanguageObject hook to change the language used in $wgLang |
96 | 96 | * (bug 14645) When $wgMiserMode is on, expensive special pages are styled |
97 | 97 | differently (italicized by default) on Special:SpecialPages |
| 98 | +* Added $wgAggregateStatsID, which allows UDP stats to be aggregated over |
| 99 | + several wikis. |
98 | 100 | |
99 | 101 | === Bug fixes in 1.18 === |
100 | 102 | * (bug 23119) WikiError class and subclasses are now marked as deprecated |