From: Timo Tijhof Date: Tue, 1 Sep 2015 19:15:53 +0000 (+0200) Subject: resourceloader: Use increment() for resourceloader_cache miss metric X-Git-Tag: 1.31.0-rc.0~10180^2 X-Git-Url: http://git.cyclocoop.org///%22%40url%40//%22?a=commitdiff_plain;h=f28e51adafc0c8a40518d6f9f58b340c7d9a5087;p=lhc%2Fweb%2Fwiklou.git resourceloader: Use increment() for resourceloader_cache miss metric This makes it consistent with how we handle the resourceloader_cache hit metric. When I added the miss metric I figured it was nice to get both counts and timings in a single metric, but I can't trust StatsD/Graphite not to screw this up so let's untangle them to be sure. Change-Id: I24f68e34a9fa491806fdb6023bdd757f6688c2ed --- diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index fd2263bfd2..5fb6c96d5a 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -191,6 +191,7 @@ class ResourceLoader implements LoggerAwareInterface { } // Defaults $options += array( 'cache' => true, 'cacheReport' => false ); + $stats = RequestContext::getMain()->getStats(); // Don't filter empty content if ( trim( $data ) === '' ) { @@ -211,18 +212,16 @@ class ResourceLoader implements LoggerAwareInterface { $cache = wfGetCache( wfIsHHVM() ? CACHE_ACCEL : CACHE_ANYTHING ); $cacheEntry = $cache->get( $key ); if ( is_string( $cacheEntry ) ) { - wfIncrStats( "resourceloader_cache.$filter.hit" ); + $stats->increment( "resourceloader_cache.$filter.hit" ); return $cacheEntry; } $result = ''; try { - $stats = RequestContext::getMain()->getStats(); $statStart = microtime( true ); - $result = self::applyFilter( $filter, $data, $this->config ); - $statTiming = microtime( true ) - $statStart; - $stats->timing( "resourceloader_cache.$filter.miss", 1000 * $statTiming ); + $stats->increment( "resourceloader_cache.$filter.miss" ); + $stats->timing( "resourceloader_cache.$filter.timing", 1000 * $statTiming ); if ( $options['cacheReport'] ) { $result .= "\n/* cache key: $key */"; }