public static function isEnabled() { if (self::$enabled === null) { self::$enabled = ini_get("pinba.enabled") === "1"; } return self::$enabled; }
public function __construct($host = SocketMemcached::DEFAULT_HOST, $port = SocketMemcached::DEFAULT_PORT, $buffer = SocketMemcached::DEFAULT_BUFFER) { if (PinbaClient::isEnabled()) { PinbaClient::me()->timerStart('memcached_' . $host . '_' . $port . '_connect', array('memcached_connect' => $host . '_' . $port)); } parent::__construct($host, $port, $buffer); if (PinbaClient::isEnabled()) { PinbaClient::me()->timerStop('memcached_' . $host . '_' . $port . '_connect'); } }
public function testTreeLog() { PinbaClient::me()->setTreeLogEnabled(); $this->assertEquals(count(PinbaClient::me()->getTreeQueue()), 0); PinbaClient::me()->timerStart('test', array("test" => 'main')); $this->assertEquals(count(PinbaClient::me()->getTreeQueue()), 1); PinbaClient::me()->timerStart('subtest', array("test" => 'submain')); $this->assertEquals(count(PinbaClient::me()->getTreeQueue()), 2); PinbaClient::me()->timerStop('subtest'); $this->assertEquals(count(PinbaClient::me()->getTreeQueue()), 1); PinbaClient::me()->timerStop('test'); $this->assertEquals(count(PinbaClient::me()->getTreeQueue()), 0); }
public function queryRaw($queryString) { if (PinbaClient::isEnabled()) { $queryLabel = substr($queryString, 0, 5); PinbaClient::me()->timerStart('pg_sql_query_' . $this->basename, array('group' => 'sql', 'pg_sql_query' => $queryLabel, 'pg_sql_server' => $this->hostname, 'pg_sql_base' => $this->basename)); } try { $result = parent::queryRaw($queryString); if (PinbaClient::isEnabled()) { PinbaClient::me()->timerStop('pg_sql_query_' . $this->basename); } return $result; } catch (Exception $e) { if (PinbaClient::isEnabled()) { PinbaClient::me()->timerStop('pg_sql_query_' . $this->basename); } throw $e; } Assert::isUnreachable(); }
private function stopLog($methodName) { if (PinbaClient::isEnabled()) { PinbaClient::me()->timerStop('pecl_memcached_' . $this->host . '_' . $this->port . '_' . $methodName); } }