From bf27bbb181f119a6c6278d618d5f21518eff45c7 Mon Sep 17 00:00:00 2001 From: Ori Livneh Date: Wed, 1 Jul 2015 17:25:24 -0700 Subject: [PATCH] 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 --- includes/Hooks.php | 1 + includes/api/ApiMain.php | 2 ++ 2 files changed, 3 insertions(+) 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(), '+', '.' ) ); } /** -- 2.20.1