Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/259543

Change subject: Make ApiStashEdit use statsd metrics
......................................................................

Make ApiStashEdit use statsd metrics

Change-Id: Iffdeae7f867490e3c69c4b6d79a5f844cb7fce23
---
M includes/api/ApiStashEdit.php
1 file changed, 13 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/43/259543/1

diff --git a/includes/api/ApiStashEdit.php b/includes/api/ApiStashEdit.php
index 208e9ca..9d8fc26 100644
--- a/includes/api/ApiStashEdit.php
+++ b/includes/api/ApiStashEdit.php
@@ -252,6 +252,9 @@
        public static function checkCache( Title $title, Content $content, User 
$user ) {
                $cache = ObjectCache::getLocalClusterInstance();
                $logger = LoggerFactory::getInstance( 'StashEdit' );
+               $stats = RequestContext::getMain()->getStats();
+
+               $stats->increment( "editstash.cache-checks" );
 
                $key = self::getStashKey( $title, $content, $user );
                $editInfo = $cache->get( $key );
@@ -267,20 +270,23 @@
                                $editInfo = $cache->get( $key );
                                $dbw->unlock( $key, __METHOD__ );
                        }
-                       $sec = microtime( true ) - $start;
-                       if ( $sec > .01 ) {
-                               $logger->warning( "Waited $sec seconds on 
'$key'." );
-                       }
+
+                       $timeMs = 1000 * max( 0, microtime( true ) - $start );
+                       $stats->timing( "editstash.lock-wait-time", $timeMs );
                }
 
                if ( !is_object( $editInfo ) || !$editInfo->output ) {
+                       $stats->increment( "editstash.cache-misses" );
                        $logger->debug( "No cache value for key '$key'." );
+
                        return false;
                }
 
                $time = wfTimestamp( TS_UNIX, $editInfo->output->getTimestamp() 
);
                if ( ( time() - $time ) <= 3 ) {
+                       $stats->increment( "editstash.cache-hits" );
                        $logger->debug( "Timestamp-based cache hit for key 
'$key'." );
+
                        return $editInfo; // assume nothing changed
                }
 
@@ -308,6 +314,7 @@
                        }
 
                        if ( $changed || $res->numRows() != $templateUses ) {
+                               $stats->increment( "editstash.cache-misses" );
                                $logger->info( "Stale cache for key '$key'; 
template changed." );
                                return false;
                        }
@@ -331,11 +338,13 @@
                        }
 
                        if ( $changed || $res->numRows() != count( $files ) ) {
+                               $stats->increment( "editstash.cache-misses" );
                                $logger->info( "Stale cache for key '$key'; 
file changed." );
                                return false;
                        }
                }
 
+               $stats->increment( "editstash.cache-hits" );
                $logger->debug( "Cache hit for key '$key'." );
 
                return $editInfo;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iffdeae7f867490e3c69c4b6d79a5f844cb7fce23
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to