-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathCatDemo.php
96 lines (78 loc) · 1.89 KB
/
CatDemo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
use Message\Message;
/**
* @author: [email protected]
* Date: 16/7/19 下午2:23
*/
function __autoload($class)
{
$path = str_replace("\\", "/", $class);
require_once($path . '.php');
}
class ExceptionTest
{
function methodThrowsException()
{
throw new Exception;
}
public function run()
{
try {
$a = $this->methodThrowsException();
echo $a;
echo "hello, world!!!\n";
} catch (Exception $e) {
Cat::logError('Error', get_class($e), $e);
}
}
}
//$test = new ExceptionTest();
//$test->run();
class TransactionTest
{
public function run()
{
$transaction = Cat::newTransaction("URL", "/Test");
{
$t1 = Cat::newTransaction('Invoke', 'method1()');
sleep(2);
$t1->setStatus(Message::SUCCESS);
$t1->addData("Hello", "world");
$t1->complete();
}
{
$t2 = Cat::newTransaction('Invoke', 'method2()');
sleep(2);
$t2->setStatus(Message::SUCCESS);
$t2->complete();
}
{
$t3 = Cat::newTransaction('Invoke', 'method3()');
sleep(1);
{
$t4 = Cat::newTransaction('Invoke', 'method4()');
sleep(2);
$t4->setStatus(Message::SUCCESS);
$t4->complete();
}
$t3->setStatus(Message::SUCCESS);
$t3->complete();
}
$transaction->setStatus(Message::SUCCESS);
$transaction->addData("Hello, world!");
$transaction->complete();
}
}
class MetricDemo
{
public function run()
{
Cat::logMetricForCount("支付笔数");
Cat::logMetricForSum("支付总额", 100.5);
}
}
//$metricTest = new MetricDemo();
//
//$metricTest->run();
$test = new TransactionTest();
$test->run();