Added statsd metrics for ObjectCacheSessionHandler
authorAaron Schulz <aschulz@wikimedia.org>
Mon, 10 Aug 2015 23:25:25 +0000 (16:25 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 13 Aug 2015 20:04:28 +0000 (13:04 -0700)
Change-Id: I86e967a027e2010f962831b55a9fceab02d8a19e

includes/objectcache/ObjectCacheSessionHandler.php

index 1f4beb9..6a9b9a8 100644 (file)
@@ -108,7 +108,11 @@ class ObjectCacheSessionHandler {
         * @return mixed Session data
         */
        static function read( $id ) {
+               $stime = microtime( true );
                $data = self::getCache()->get( self::getKey( $id ) );
+               $real = microtime( true ) - $stime;
+
+               RequestContext::getMain()->getStats()->timing( "session.read", $real );
 
                self::$hashCache = array( $id => self::getHash( $data ) );
 
@@ -129,7 +133,11 @@ class ObjectCacheSessionHandler {
                if ( !isset( self::$hashCache[$id] )
                        || self::getHash( $data ) !== self::$hashCache[$id]
                ) {
+                       $stime = microtime( true );
                        self::getCache()->set( self::getKey( $id ), $data, $wgObjectCacheSessionExpiry );
+                       $real = microtime( true ) - $stime;
+
+                       RequestContext::getMain()->getStats()->timing( "session.write", $real );
                }
 
                return true;
@@ -142,7 +150,11 @@ class ObjectCacheSessionHandler {
         * @return bool Success
         */
        static function destroy( $id ) {
+               $stime = microtime( true );
                self::getCache()->delete( self::getKey( $id ) );
+               $real = microtime( true ) - $stime;
+
+               RequestContext::getMain()->getStats()->timing( "session.destroy", $real );
 
                return true;
        }