jenkins-bot has submitted this change and it was merged.

Change subject: Count API module instantiations and Hook runs
......................................................................


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
---
M includes/Hooks.php
M includes/api/ApiMain.php
2 files changed, 3 insertions(+), 0 deletions(-)

Approvals:
  Gergő Tisza: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Hooks.php b/includes/Hooks.php
index 036d65c..28c54d2 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -135,6 +135,7 @@
         *   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 f2059d7..fec750f 100644
--- a/includes/api/ApiMain.php
+++ b/includes/api/ApiMain.php
@@ -404,6 +404,8 @@
                } else {
                        $this->executeActionWithErrorHandling();
                }
+               $this->getContext()->getStats()->increment(
+                       'api.modules.' . strtr( 
$this->getModule()->getModulePath(), '+', '.' ) );
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/222224
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic04daf475b936b942833362c7a979dde671b3ef4
Gerrit-PatchSet: 8
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <o...@wikimedia.org>
Gerrit-Reviewer: Anomie <bjor...@wikimedia.org>
Gerrit-Reviewer: BryanDavis <bda...@wikimedia.org>
Gerrit-Reviewer: Gergő Tisza <gti...@wikimedia.org>
Gerrit-Reviewer: Ori.livneh <o...@wikimedia.org>
Gerrit-Reviewer: Parent5446 <tylerro...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to