What we have supported and what we are going to support: support plan
Dependency | Version |
---|---|
PHP | php 7+ ,5+ |
GCC | GCC 4.7+ |
cmake | cmake 3.8+ |
*inux | |
Python | Python 3 |
pinpoint | 1.8.0+ , 2.0+ |
Composer |
-
git clone https://github.com/pinpoint-apm/pinpoint-c-agent.git
-
Build Collector-Agent by yourself or use Dockerized Collector-Agent, just choose one way:
-
Use Dockerized Collector-Agent:
``` docker pull eeliu2020/pinpoint-collector-agent:latest docker run --add-host collectorHost:your-pinpoint-hostname -d -p 9999:9999 eeliu2020/pinpoint-collector-agent ```
-
Build pinpoint-php-module, goto the root directory of pinpoint-c-agent installation package, and do following steps:
-
phpize
-
./configure
-
make
-
make test TESTS=src/PHP/tests/
ps: We recommend you to test whether the module is RIGHT. For PHP5:
make test TESTS=src/PHP/tests5/
-
make install
-
Activate pinpoint-php-module, please add the following configuration into your
php.ini
php.ini
extension=pinpoint_php.so ; Collector-agent's TCP address, ip,port:Collector-Agent's ip,port, please insure it consistent with that in step2(Build Collector-Agent). pinpoint_php.CollectorHost=Tcp:ip:port ; or unix:(unix sock address) ;pinpoint_php.CollectorHost=unix:/tmp/collector-agent.sock pinpoint_php.SendSpanTimeOutMs=0 # 0 is recommanded ; request should be captured duing 1 second. < 0 means no limited pinpoint_php.TraceLimit=-1 ; DEBUG the agent, PHP's log_error should turn on too. ;pinpoint_php.DebugReport=true ;error_reporting = E_ALL ;log_errors = On ;error_log = /tmp/php_fpm_error.log
-
-
Use Pinpoint PHP Agent in your project, and follow the steps below:
We assume that you have installed composer and known how to use it. How to Use Composer?
-
Copy Plugins to the root of your project, and autoload
Plugins
incomposer.json
.composer.json
"autoload": { "psr-4": { ...... "Plugins\\": path to the Plugins } },
-
Add
pinpoint-apm/pinpoint-php-aop
into composer.json and update."require": { ... "pinpoint-apm/pinpoint-php-aop": "v2.0.1" }
-
Add the following constants in the index file of your project, including:
################################################# define('APPLICATION_NAME','APP-2'); define('APPLICATION_ID','app-2'); define('AOP_CACHE_DIR',__DIR__.'./Cache/'); define('PLUGINS_DIR',__DIR__.'./Plugins/'); define('PINPOINT_USE_CACHE','YES'); define('PP_REQ_PLUGINS', '\Plugins\PerRequestPlugins'); #define('USER_DEFINED_CLASS_MAP_IMPLEMENT',"\Plugins\Framework\app\ClassMapInFile"); require_once __DIR__. path to 'vendor/pinpoint-apm/pinpoint-php-aop/auto_pinpointed.php'; #################################################
APPLICATION_NAME
: Application name.APPLICATION_ID
: Agent ID.AOP_CACHE_DIR
: Where to generateCache
.PLUGINS_DIR
: Path toPlugins
.PINPOINT_USE_CACHE
: 'YES' will not updateCache
when request coming; 'No' will updateCache
every request coming.(You can also updateCache
by just delete it.) Considering the performance, recommond 'YES'. Further more, if you modify the plugins, you should update theCache
to take effect.PP_REQ_PLUGINS
: path toPerRequestPlugins
(PerRequestPlugins
is the base interceptor, different framework should use differentPerRequestPlugins
) Where is PerRequestPlugins?Swoole
for example: swoole's PerRequestPlugins. We have prepared some framework'sPerRequestPlugins
for you Here, and welcome to pull request other frameworks.require_once __DIR__. path to 'vendor/pinpoint-apm/pinpoint-php-aop/auto_pinpointed.php';
: Require pinpoint'sauto_pinpointed.php
.Please add afterrequire_once __DIR__."/../vendor/autoload.php";
, this is very important!
We have prepared some examples for you, please goto plugins/PHP.
-
- Fully support ZTS
- More stability
- Higher performance
- Easily use and maintain
- Support GRPC
Delete __class_index_table in Cache/
We can DO but prefer not to DO! Because we have not yet found an efficient way to implement this and monitoring these files status every time is a bad deal.
After full test, the AOP code could spend at least 1ms in our env(E5-2660 v4 @ 2.00GHz). While, the more function/method you monitor, the more you take.
3.1 Test Result ☚
Sorry, pinpoint-php-aop
does not support to wrap the user class (or internal class) without composer/autoloader. By the way, Composer is GOOD. O(∩_∩)O