From 1204f0dee4d2afde76ea3f2f26223d45cc4402bb Mon Sep 17 00:00:00 2001 From: Keith Herron Date: Fri, 26 Jan 2024 13:00:09 -0500 Subject: [PATCH] ResourceLoader: Convert resourceloader_build metric to statslib Bug: T355960 Change-Id: Ida574150735560f8265133754cf27d12cb7a4221 --- includes/ResourceLoader/Module.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/includes/ResourceLoader/Module.php b/includes/ResourceLoader/Module.php index 7fc2d388b20..d5893bcf6c5 100644 --- a/includes/ResourceLoader/Module.php +++ b/includes/ResourceLoader/Module.php @@ -818,7 +818,7 @@ abstract class Module implements LoggerAwareInterface { * @return array */ final protected function buildContent( Context $context ) { - $stats = MediaWikiServices::getInstance()->getStatsdDataFactory(); + $statsFactory = MediaWikiServices::getInstance()->getStatsFactory(); $statStart = microtime( true ); // This MUST build both scripts and styles, regardless of whether $context->getOnly() @@ -903,10 +903,13 @@ abstract class Module implements LoggerAwareInterface { } $statTiming = microtime( true ) - $statStart; - $stats->timing( "resourceloader_build.all", 1000 * $statTiming ); - $name = $this->getName(); - $statName = strtr( $name, '.', '_' ); - $stats->timing( "resourceloader_build.$statName", 1000 * $statTiming ); + $statName = strtr( $this->getName(), '.', '_' ); + + $statsFactory->getTiming( 'resourceloader_build_seconds' ) + ->setLabel( 'name', $statName ?: 'na' ) + ->copyToStatsdAt( [ "resourceloader_build.$statName", + 'resourceloader_build.all' ] ) + ->observe( 1000 * $statTiming ); return $content; }