Skip to content

Commit fcab4e7

Browse files
committed
* a bit pinba tune. See changelog for details.
1 parent 37aa8bd commit fcab4e7

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

doc/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2012-04-11 Evgeny V. Kokovikhin
2+
3+
* main/Monitoring/PinbaClient.class.php: base ability of
4+
tree (integral) logging added. thanks to Artem A. Naumenko
5+
16
2012-04-04 Georgiy T. Kutsurua
27

38
* main/UI/View/JsonPView.class.php,

main/Monitoring/PinbaClient.class.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ final class PinbaClient extends Singleton
1717
{
1818
private static $enabled = null;
1919
private $timers = array();
20+
private $queue = array();
21+
private $treeLogEnabled = false;
22+
2023

2124
/**
2225
* @return PinbaClient
@@ -34,11 +37,36 @@ public static function isEnabled()
3437
return self::$enabled;
3538
}
3639

40+
public function setTreeLogEnabled($orly = true)
41+
{
42+
$this->treeLogEnabled = ($orly === true);
43+
44+
return $this;
45+
}
46+
47+
public function isTreeLogEnabled()
48+
{
49+
return $this->treeLogEnabled;
50+
}
51+
3752
public function timerStart($name, array $tags, array $data = array())
3853
{
3954
if (array_key_exists($name, $this->timers))
4055
throw new WrongArgumentException('a timer with the same name allready exists');
4156

57+
if ($this->isTreeLogEnabeled()) {
58+
59+
$id = uniqid();
60+
$tags['treeId'] = $id;
61+
62+
if (!empty($this->queue))
63+
list($tags['treeParentId']) = end($this->queue);
64+
else
65+
$tags['treeParentId'] = 'root';
66+
67+
$this->queue[] = $id;
68+
}
69+
4270
$this->timers[$name] =
4371
count($data)
4472
? pinba_timer_start($tags, $data)
@@ -49,6 +77,9 @@ public function timerStart($name, array $tags, array $data = array())
4977

5078
public function timerStop($name)
5179
{
80+
if ($this->isTreeLogEnabeled())
81+
array_pop($this->queue);
82+
5283
if (!array_key_exists($name, $this->timers))
5384
throw new WrongArgumentException('have no any timer with name '.$name);
5485

0 commit comments

Comments
 (0)