From: Ori Livneh Date: Thu, 2 Jul 2015 00:25:24 +0000 (-0700) Subject: Count API module instantiations and Hook runs X-Git-Tag: 1.31.0-rc.0~10882^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=commitdiff_plain;h=bf27bbb181f119a6c6278d618d5f21518eff45c7;p=lhc%2Fweb%2Fwiklou.git Count API module instantiations and Hook runs We previously had counts for hooks and modules as a side-effect of having them profiled. We removed the profiling for performance reasons, which left us without counts also. But the performance of counters is not a concern, and their signal value not insubstantial. So introduce them here. Fix getModulePath() to not crash while we're at it. Change-Id: Ic04daf475b936b942833362c7a979dde671b3ef4 --- diff --git a/includes/Hooks.php b/includes/Hooks.php index 036d65c71e..28c54d2033 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -135,6 +135,7 @@ class Hooks { * returning null) is equivalent to returning true. */ public static function run( $event, array $args = array(), $deprecatedVersion = null ) { + RequestContext::getMain()->getStats()->increment( 'hooks.' . $event ); foreach ( self::getHandlers( $event ) as $hook ) { // Turn non-array values into an array. (Can't use casting because of objects.) if ( !is_array( $hook ) ) { diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index f2059d759e..fec750fc1f 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -404,6 +404,8 @@ class ApiMain extends ApiBase { } else { $this->executeActionWithErrorHandling(); } + $this->getContext()->getStats()->increment( + 'api.modules.' . strtr( $this->getModule()->getModulePath(), '+', '.' ) ); } /**