-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sample.php
38 lines (31 loc) · 929 Bytes
/
Sample.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
<?php
require 'vendor/autoload.php';
use Middleware\AgentApmPhp\MwTracker;
$tracker = new MwTracker('DemoProject', 'PrintService');
$tracker->preTrack();
$tracker->registerHook('DemoClass', 'runCode', [
'code.column' => '12',
'net.host.name' => 'localhost',
'db.name' => 'users',
'custom.attr1' => 'value1',
]);
$tracker->registerHook('DoThings', 'printString');
$tracker->warn("this is warning log.");
$tracker->error("this is error log.");
$tracker->info("this is info log.");
$tracker->debug("this is debug log.");
class DoThings {
public static function printString($str): void {
// sleep(1);
global $tracker;
$tracker->warn("this is warning log, but from inner function.");
echo $str . PHP_EOL;
}
}
class DemoClass {
public static function runCode(): void {
DoThings::printString('Hello World!');
}
}
DemoClass::runCode();
$tracker->postTrack();