end of maintain : goto https://github.com/pinpoint-apm/pinpoint-php-aop?tab=readme-ov-file#write-your-own-plugins
-
First, you need to know how to use pinpoint-php-aop ☚ and how it works.
-
Write your own XXXPlugin.php class.
use Pinpoint\Plugins\Common\PinTrace; class XXXPlugins extends PinTrace { public function onBefore(){ pinpoint_add_clue("stp",PHP_METHOD); pinpoint_add_clues(PHP_ARGS,"fetch data from $this->args"); } public function onEnd(&$ret){ pinpoint_add_clues(PHP_RETURN,"parse data from $ret"); } public function onException($e){ pinpoint_add_clue("EXP",$e->getMessage()); } }
You could find some out of box plugins in [Plugins Example]. When you add clue(clues), DO NOT assignment with large string or string included some special characters(https://www.freeformatter.com/json-escape.html)
-
Add the function that you care about such as "///@hook:app\User::adduser" before ClassName(XXXPlugins), onBefore, onEnd or onException. If you care about all cases, please call before&after&around function.
-
Inject plugin into your project: $ cd your_project_folder $ mkdir Plugins/AutoGen $ cp your_xxxplugins.php Plugins/AutoGen
-
Enable autoloading Plugins/ into composer.json
"autoload": { "psr-4": { ...... # location for your Plugins "Plugins\\": "Plugins" } },
-
Update your autoload. $composer update.
Json -> Thrift/GRPC
+------------------+
| php-fpm |
| pinpoint_php.so |
+------------------+
|
json |
unix:socket |
v
+----------------+
|collector-agent |
| |
+----------------+
|
| thrift TCP&UDP
| GRPC
v
+----------------------+
| pinpoint collector |
+----------------------+