diff --git a/DOC/API/collector-agent/Readme.md b/DOC/API/collector-agent/Readme.md index 5e8c8ddc7..f6af41391 100644 --- a/DOC/API/collector-agent/Readme.md +++ b/DOC/API/collector-agent/Readme.md @@ -1,27 +1,3 @@ ## Json string map to Pinpoint item -Json String | Pinpoint Name | Details -:---|:---|:--- -tid|transactionId|Transaction ID -sid|SpanId|Span ID -S|startTime|Start time of request -E|elapsed|Elapse time -FT|front type|Language type(PHP:1500, Python:1700) -appname|applicationName|Application name -appid|agentId|Agent ID -stp|serviceType|Service type([See details](https://github.com/naver/pinpoint/blob/master/commons/src/main/java/com/navercorp/pinpoint/common/trace/ServiceType.java)) -name| apids|Function name -uri|rpc|URI -clues|TAnnotation|-1:arguments
14:return
40:http url
41:http param
42:http param entity
45:cookies
46:http status code -psid|parentSpanId|Parent span ID -nsid|nextSpanId|Next span ID -dst|destinationId|Destination ID -client|remoteAddr|Client address -server|endPoint|Server address -ERR|err|Error -EXP|exp|Exception -pname|parentApplicationName|Parent application name -ptype|parentApplicationType|Parent application type -Ah|acceptorHost|Acceptor host -NP|NginxProxy header|Nginx proxy header -AP|ApacheProxy header|Apache proxy header +Go to file https://github.com/pinpoint-apm/pinpoint-c-agent/blob/1992a082d370cac1496e48fbe8de3851016ef20a/collector-agent/agent/AgentRouter.go#L73 \ No newline at end of file diff --git a/DOC/C-CPP/Readme.md b/DOC/C-CPP/Readme.md index 6d480a2d9..8017ea6df 100644 --- a/DOC/C-CPP/Readme.md +++ b/DOC/C-CPP/Readme.md @@ -34,7 +34,7 @@ FetchContent_Declare( GIT_REPOSITORY https://github.com/pinpoint-c-agent/pinpoint-c-agent.git # GIT_TAG 74bc39d813d664cb56b78b1506d91932c8131396 # not recommended, please use hash key like `74bc39d813d664cb56b78b1506d91932c8131396` - GIT_TAG origin/dev + GIT_TAG origin/v0.4.13 ) FetchContent_GetProperties(pinpoint) diff --git a/DOC/PHP/Readme.md b/DOC/PHP/Readme.md index e56dde914..0947edd16 100644 --- a/DOC/PHP/Readme.md +++ b/DOC/PHP/Readme.md @@ -49,7 +49,7 @@ collector-agent| [installed ?](../collector-agent/readme.md) 1. Use `composer require` ``` - composer require pinpoint-apm/pinpoint-php-aop + composer require pinpoint-apm/pinpoint-php-aop:v2.1.0 ``` 2. Add the following constants in the index file of your project: diff --git a/DOC/PHP/User Manual-CN.md b/DOC/PHP/User Manual-CN.md deleted file mode 100644 index ddc5f9080..000000000 --- a/DOC/PHP/User Manual-CN.md +++ /dev/null @@ -1,105 +0,0 @@ -## 1 pinpoint-php agent是如何工作的? - -Pinpoint-php agent将[pinpoint-php-aop](https://github.com/pinpoint-apm/pinpoint-php-aop)作为它的方面编程库,它有助于将origin class.php转换为proxied_class.php,其中包括plugins.php和origin.php,而不影响origin class.php的任何函数。 - -``` php -+--------------+ +-----------------------+ -| origin.php | | origin.php | -| | | proxied_origin.php | -+--------------+ | require_origin.php | - | entry for plugins.php | - ^ +-----------------------+ - | - | Before ^ - | | After - | | - +----+ vender/class_loader +-------+ - -``` - -## 1.1 性能测试结果 - -> TPS 损耗 和 TPR 损耗 - -![FlarumPerformanceTest](../images/FlarumPerformanceTest.png) - -> TPS: time per request(每个请求的响应时间) - ->TPR: requests per second(每秒的请求数量) - -[如何在Flarum中使用pinpoint-php agent ?](https://github.com/eeliu/pinpoint-in-laravel) - -> 调用栈 - -![CallTree](../images/Flarum-callstack.png) - -> 总结 -* 当Flarum添加PHP Agent时,损失小于5%。 - -如果您特别在意性能损耗问题,可以直接调用由C&C++编写的pinpoint-php agent模块API。 [(pinpoint-php api)](../../src/PHP/pinpoint_php_api.php) - -## 2 如何hook a object? - -``` -use A\a as a; -class Foo{ - public function foo(): a - { - return new a::factory_create_new(); - } -} - -``` - -> 当foo返回一个新对象时,pinpoint-php-aop很难检测到这个场景。 - -### 2.1 使用一个装饰器 - -用onEnd()中的修饰对象替换返回对象。这里有一些[魔术方法](https://www.php.net/manual/en/language.oop5.magic.php)可以帮助“破解”对象。 - -[ [如何运作 ☚]](../../plugins/PHP/Plugins/Common/InstancePlugins.php) - - -### 2.2 示例 - -#### 2.2.1 Hook a generator - -> https://github.com/pinpoint-apm/pinpoint-c-agent/issues/100 - -``` php - ... - function generator($start, $limit, $step=1){ - if($start > $limit){ - throw new LogicException("start cannot bigger that limit."); - } - usleep(120000); - for($i = $start; $i<=$limit; $i += $step){ - try{ - yield $i; - }catch (Exception $exception){ - echo $exception->getMessage(); - } - } - } - ... -``` -[ [跳转到 GeneratorPlugin ☚] ](../../testapps/PHP/Plugins/AutoGen/app/GeneratorPlugin.php) - -#### 2.2.2 PDO::prepare方法返回了一个PDOStatement类 - -``` php -Reference: https://www.php.net/manual/zh/pdo.prepare.php -prepare('SELECT name, colour, calories - FROM fruit - WHERE calories < ? AND colour = ?'); -$sth->execute(array(150, 'red')); -$red = $sth->fetchAll(); -$sth->execute(array(175, 'yellow')); -$yellow = $sth->fetchAll(); -?> - -``` - -用[ProfilerPDOStatement](https://github.com/pinpoint-apm/pinpoint-php-aop/tree/master/lib/Pinpoint/Plugins/Sys/PDO/ProfilerPDOStatement.php)替换$dbh->prepare方法的返回值 diff --git a/DOC/PHP/User Manual.md b/DOC/PHP/User Manual.md deleted file mode 100644 index 63ba6511e..000000000 --- a/DOC/PHP/User Manual.md +++ /dev/null @@ -1,106 +0,0 @@ -## 1 How does pinpoint-php agent work? - -Pinpoint-php agent employs [pinpoint-php-aop](https://github.com/pinpoint-apm/pinpoint-php-aop) as its aspect programming library, and it helps to convert origin class.php to proxied_class.php which includes plugins.php and origin.php without affecting any function of origin class.php. - -``` php -+--------------+ +-----------------------+ -| origin.php | | origin.php | -| | | proxied_origin.php | -+--------------+ | require_origin.php | - | entry for plugins.php | - ^ +-----------------------+ - | - | Before ^ - | | After - | | - +----+ vender/class_loader +-------+ - -``` - -## 1.1 Performance Result - -> TPS loss and TPR Loss - -![FlarumPerformanceTest](../images/FlarumPerformanceTest.png) - -> TPS: time per request - -> TPR: requests per second - -[How to use pinpoint-php agent into Flarum?](https://github.com/eeliu/pinpoint-in-laravel) - -> Call Tree - -![CallTree](../images/Flarum-callstack.png) - -> Summary -* Less than 5% loss, when Flarum adds PHP Agent. - -If you care about the performance most, you can call pinpoint-php agent module API directly, which is written by C&C++. [(pinpoint-php api)](../../src/PHP/pinpoint_php_api.php) - -## 2 How to hook a object ? - -``` -use A\a as a; -class Foo{ - public function foo(): a - { - return new a::factory_create_new(); - } -} - -``` - -> As foo returns a new object and this scenario can't be detected by pinpoint-php-aop easily. - -### 2.1 Use a decorator - -Replace the return object with a decorated object in onEnd(). There are some [magic methods](https://www.php.net/manual/en/language.oop5.magic.php) to help "hacking" the object. - -[ [How does it work? ☚]](../../plugins/PHP/Plugins/Common/InstancePlugins.php) - - -### 2.2 Examples - -#### 2.2.1 Hook a generator. - -> https://github.com/pinpoint-apm/pinpoint-c-agent/issues/100 - -``` php - ... - function generator($start, $limit, $step=1){ - if($start > $limit){ - throw new LogicException("start cannot bigger that limit."); - } - usleep(120000); - for($i = $start; $i<=$limit; $i += $step){ - try{ - yield $i; - }catch (Exception $exception){ - echo $exception->getMessage(); - } - } - } - ... -``` -[ [Goto GeneratorPlugin ☚] ](../../testapps/PHP/Plugins/AutoGen/app/GeneratorPlugin.php) - -#### 2.2.2 PDO::prepare return a PDOStatement - -``` php -Reference: https://www.php.net/manual/zh/pdo.prepare.php -prepare('SELECT name, colour, calories - FROM fruit - WHERE calories < ? AND colour = ?'); -$sth->execute(array(150, 'red')); -$red = $sth->fetchAll(); -$sth->execute(array(175, 'yellow')); -$yellow = $sth->fetchAll(); -?> - -``` - -Replace $dbh->prepare return value with [ProfilerPDOStatement](https://github.com/pinpoint-apm/pinpoint-php-aop/tree/master/lib/Pinpoint/Plugins/Sys/PDO/ProfilerPDOStatement.php). - diff --git a/DOC/PY/Readme.md b/DOC/PY/Readme.md index bc163ef93..423b2a311 100644 --- a/DOC/PY/Readme.md +++ b/DOC/PY/Readme.md @@ -7,16 +7,13 @@ Dependency| Version| More ---|----|--- python |3+ | (async must 3.7.1+) -GO | | -gcc|gcc 4.7+| c++11 *inux| | `windows` is on the way -pinpoint| 2.0+(GRPC)| collector-agent| [installed ?](../collector-agent/readme.md) ### Installation ```shell -$ pip install pinpointPy +$ pip install pinpointPy==1.1.0 ``` ### How to Use diff --git a/DOC/collector-agent/readme.md b/DOC/collector-agent/readme.md index fb5795b37..a0c4ddbc9 100644 --- a/DOC/collector-agent/readme.md +++ b/DOC/collector-agent/readme.md @@ -1,9 +1,9 @@ ## Install Collector Agent -`Collector-Agent`, who formats the span from PHP/Python/C/CPP-Agent and send to `Pinpoint-Collector`, is an agent written by [golang](https://golang.google.cn/).Please install golang before the following steps.[Install GO](https://golang.google.cn/doc/install) +`Collector-Agent` formats the span from PHP/Python/C/CPP-Agent and send to `Pinpoint-Collector`. -### Steps +### 1. build from source 1. Goto collector-agent(`pinpoint-c-agent/collector-agent`) -2. Execute command `go build` +2. Execute command `make` 3. Add environment variables: ``` export PP_COLLECTOR_AGENT_SPAN_IP=dev-pinpoint @@ -24,11 +24,38 @@ 5. `PP_ADDRESS`: Set the address of `Collector-Agent`, then `PHP/Python-Agent` will connect Collector-Agent through this address. 4. Run `Collector-Agent` by executing command `./CollectorAgent` -### Use docker images +### 2. Use docker images ```sh -docker run -itd -p 9999:9999 --env-file ./env.list ghcr.io/pinpoint-apm/pinpoint-c-agent/collector-agent:0.4.25 +docker run -itd -p 9999:9999 --env-file ./env.list ghcr.io/pinpoint-apm/pinpoint-c-agent/collector-agent:0.4.13 ``` +### 3. K8s side car +server.yaml sample - +``` yml +- image: ghcr.io/pinpoint-apm/pinpoint-c-agent/collector-agent:0.4.13 + name: collector-agent + args: ["-RecvBufSize=1048576"] + securityContext: + runAsUser: 0 + env: + - name: "PP_COLLECTOR_AGENT_SPAN_IP" + value: "pinpoint-collector.hostname" + - name: "PP_COLLECTOR_AGENT_SPAN_PORT" + value: "9993" + - name: "PP_COLLECTOR_AGENT_AGENT_IP" + value: "pinpoint-collector.hostname" + - name: "PP_COLLECTOR_AGENT_AGENT_PORT" + value: "9991" + - name: "PP_COLLECTOR_AGENT_STAT_IP" + value: "pinpoint-collector.hostname" + - name: "PP_COLLECTOR_AGENT_STAT_PORT" + value: "9992" + - name: "PP_Log_Level" + value: "INFO" + - name: "PP_ADDRESS" + value: "localhost@9999" + - name: "PP_COLLECTOR_AGENT_ISDOCKER" + value: "true" +``` diff --git a/DOC/common/Readme.md b/DOC/common/Readme.md deleted file mode 100644 index e37451071..000000000 --- a/DOC/common/Readme.md +++ /dev/null @@ -1,44 +0,0 @@ -## Install pinpoint_common - -### Requirement - -Dependency| Version| More ----|----|--- -gcc|gcc 4.7+| c++11 -cmake| 3.13+ | ✔ -OS| *inx | - -### Steps - -1. Execute commands below: - ```shell - $ git clone https://github.com/pinpoint-apm/pinpoint-c-agent.git - $ cd pinpoint-c-agent/common - $ mkdir build && cd build - $ cmake .. && make && make install - ``` - If the installation completes successfully, you will see the infomation like following: - ``` - ... - Install the project... - -- Install configuration: "Release" - -- Up-to-date: /usr/local/include/pinpoint_common - -- Up-to-date: /usr/local/include/pinpoint_common/common.h - -- Installing: /usr/local/lib64/libpinpoint_common_shared.so - -- Installing: /usr/local/lib64/libpinpoint_common.a - -- Installing: /usr/local/lib64/pkgconfig/pinpoint_common.pc - ``` - ps: The real install path depends on you enviroment, for the information above, the install path is `/usr/local/lib64` - -2. Export the pinpoint lib installing path to `LD_LIBRARY_PATH` `PKG_CONFIG_PATH` `LD_RUN_PATH` -```shell -export LD_LIBRARY_PATH=/path to pinpoint lib/:$LD_LIBRARY_PATH -export PKG_CONFIG_PATH=/path to pinpoint lib/:/path to pinpoint lib/pkgconfig:$PKG_CONFIG_PATH -export LD_RUN_PATH=/path to pinpoint lib/:$LD_RUN_PATH -``` - -### Use docker images - -``` dockerfile -from ghcr.io/pinpoint-apm/pinpoint-c-agent/golang-build-env-1.13:latest as gobuilder -``` diff --git a/README.md b/README.md index f452bb1e5..61bbfcf81 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ language| tutorial php|[English](DOC/PHP/Readme.md) [中文](DOC/PHP/Readme-CN.md) [한국어](DOC/PHP/Readme-KR.md) python3|[English](DOC/PY/Readme.md) [中文](DOC/PY/Readme-CN.md) [한국어](DOC/PY/Readme-KR.md) c/cpp|[English](DOC/C-CPP/Readme.md) -golang|[go-aop-agent](https://github.com/pinpoint-apm/go-aop-agent) +golang|[go-aop-agent](https://github.com/pinpoint-apm/go-aop-agent) (_experiment_) > [Try playground](/testapps/readme.md) diff --git a/testapps/compose.yaml b/testapps/compose.yaml index 1c990b019..b7254b59e 100644 --- a/testapps/compose.yaml +++ b/testapps/compose.yaml @@ -55,6 +55,11 @@ services: ports: - 8184:80 + healthcheck: + test: curl -f http://testapp-flask + interval: 5s + timeout: 1s + testapp-php: container_name: yii2 depends_on: @@ -67,6 +72,11 @@ services: ports: - 8185:80 + healthcheck: + test: curl -f http://testapp-php + interval: 5s + timeout: 1s + testapp-fastapi: container_name: fastapi depends_on: @@ -78,6 +88,10 @@ services: context: ../ ports: - 8186:8000 + healthcheck: + test: curl -f http://testapp-fastapi:8000 + interval: 5s + timeout: 1s # test call self backend: @@ -91,6 +105,11 @@ services: context: ../ ports: - 8187:80 + + healthcheck: + test: curl -f http://backend + interval: 5s + timeout: 1s testapp-django: container_name: django @@ -103,6 +122,10 @@ services: context: ../ ports: - 8188:8000 + healthcheck: + test: curl -f http://testapp-django:8000/polls + interval: 5s + timeout: 1s httpbin: build: @@ -110,7 +133,7 @@ services: context: ../ restart: always healthcheck: - test: curl -f http://localhost + test: curl -f http://httpbin interval: 5s timeout: 10s retries: 50