Skip to content

Commit d1773c4

Browse files
authored
release php-agent (#692)
1 parent 5885781 commit d1773c4

File tree

16 files changed

+141
-36
lines changed

16 files changed

+141
-36
lines changed

DOC/C-CPP/Readme.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,9 @@ $ ./test_pinpoint.cpp
4949
### Test apps example
5050

5151
- [yhirose/cpp-httplib example](../../testapps/cpp-httplib/readme.md)
52-
- [libevent/libevent example](../../testapps/libevent_http_server/readme.md)
52+
- [libevent/libevent example](../../testapps/libevent_http_server/readme.md)
53+
54+
55+
### Blogs
56+
- [pinpoint-c-agen directly monitor C/C++ applications?](https://github.com/pinpoint-apm/pinpoint-c-agent/issues/690#issuecomment-2421787446)
57+
- [Introduction for pinpoint on asynchronous framework](https://github.com/pinpoint-apm/pinpoint-c-agent/tree/0.7/testapps/libevent_http_server#introduction-for-pinpoint-on-asynchronous-framework)

package.xml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@
1616
<email>liu_ming_yi@outlook.com</email>
1717
<active>yes</active>
1818
</lead>
19-
<date>2024-10-20</date>
19+
<date>2024-10-23</date>
2020
<version>
21-
<release>0.6.0</release>
22-
<api>0.6.0</api>
21+
<release>0.6.1</release>
22+
<api>0.6.1</api>
2323
</version>
2424
<stability>
25-
<release>alpha</release>
26-
<api>alpha</api>
25+
<release>stable</release>
26+
<api>stable</api>
2727
</stability>
2828
<license uri="https://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</license>
2929
<notes>
30-
## 0.6.0 2024-10-20
31-
- release asynchronous version
30+
## 0.6.1 2024-10-23
31+
- release asynchronous version https://github.com/pinpoint-apm/pinpoint-c-agent/pull/692
3232
</notes>
3333
<contents>
3434
<dir name="/">
@@ -110,18 +110,34 @@
110110
<extsrcrelease>
111111
</extsrcrelease>
112112
<changelog>
113+
<release>
114+
<stability>
115+
<release>stable</release>
116+
<api>stable</api>
117+
</stability>
118+
<version>
119+
<release>0.6.1</release>
120+
<api>2024-10-23</api>
121+
</version>
122+
<date> 2024-10-23</date>
123+
<notes>
124+
## 0.6.0 2024-10-23 [stable]
125+
- release asynchronous version https://github.com/pinpoint-apm/pinpoint-c-agent/pull/692
126+
</notes>
127+
</release>
128+
113129
<release>
114130
<stability>
115131
<release>alpha</release>
116132
<api>alpha</api>
117133
</stability>
118134
<version>
119135
<release>0.6.0</release>
120-
<api>2024-10-20</api>
136+
<api>2024-10-21</api>
121137
</version>
122-
<date> 2024-10-20</date>
138+
<date> 2024-10-21</date>
123139
<notes>
124-
## 0.6.0 2024-10-20
140+
## 0.6.0 2024-10-21
125141
- release asynchronous version
126142
</notes>
127143
</release>

testapps/PHP/php.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ RUN cd /pinpoint-c-agent/ && phpize && ./configure && make && make install
1212
COPY testapps/PHP/php.ini /usr/local/etc/php/conf.d/pinpoint-php-ext.ini
1313

1414
RUN composer create-project --prefer-dist yiisoft/yii2-app-basic /app
15-
RUN composer require -w pinpoint-apm/pinpoint-php-aop:v3.0.2
15+
RUN composer require -w pinpoint-apm/pinpoint-php-aop
1616
RUN chown -R www-data:www-data /app
1717
# Copy index.php
1818
COPY testapps/PHP/index.php /app/web/index.php

testapps/SimplePHP/Readme.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
## Command
2+
3+
```sh
4+
$ docker compose up simple-php
5+
```
6+
7+
## How to combine kafka producer and consumer together
8+
9+
> Background: some applications use message queue as worker/task dispatcher, but how to address the task dispatcher problems?
10+
11+
Use pinpoint-php agent asynchronous API, it adds some specially header(mask) into message and collects related function call.
12+
13+
![php agent kafka flow](kafka..excalidraw.png)
14+
15+
#### Define a full span into consumer side
16+
17+
> start: kafka message response \
18+
> end: start waiting a new message
19+
20+
![full span](consumer..excalidraw.png)
21+
22+
#### Inside Code
23+
24+
1. Producer side
25+
26+
```php
27+
28+
// run.php
29+
$topic->producev(RD_KAFKA_PARTITION_UA, 0, "I'm Message $i", "key", $headers); // only support message with header(header annotation API)
30+
31+
// kafka interceptor
32+
// lib/Pinpoint/Plugins/SysV2/_rdKafka/rdKafka.php
33+
34+
$producev_on_before = function ($partition, $msgflags, $payload, $key = NULL, $headers = [], $timestamp_ms = NULL, $opaque = NULL) {
35+
pinpoint_start_trace();
36+
...
37+
}
38+
39+
pinpoint_join_cut(
40+
["RdKafka\ProducerTopic", "producev"],
41+
$producev_on_before,
42+
..
43+
);
44+
45+
```
46+
47+
2. Consumer side
48+
49+
```PHP
50+
// kafka_consumer.php
51+
$message = $consumer->consume(120 * 1000);
52+
switch ($message->err) {
53+
case RD_KAFKA_RESP_ERR_NO_ERROR:
54+
55+
$handler = new SimplePHP\MessageHandler();
56+
$handler->handle_message_in_kafka($message);
57+
break;
58+
...
59+
60+
// lib/Pinpoint/Plugins/SysV2/_rdKafka/rdKafka_consumer.php
61+
62+
$rdKafka_consumer_on_before = function ($timeout) use ($interceptor) {
63+
Logger::Inst()->debug("call rdKafka_consumer_on_before");
64+
$depth = pinpoint_get_trace_depth();
65+
switch ($depth) {
66+
case 0:
67+
pinpoint_end_trace();
68+
...}
69+
};
70+
71+
pinpoint_join_cut(
72+
["RdKafka\KafkaConsumer", "consume"],
73+
$rdKafka_consumer_on_before,
74+
...
75+
}
76+
77+
```
78+
#### Inside pinpoint
79+
80+
![alt text](image.png)
50.7 KB
Loading

testapps/SimplePHP/image.png

13.1 KB
Loading
33.8 KB
Loading

testapps/SimplePHP/simplephp.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ COPY tests /pinpoint-c-agent/tests
2121
RUN cd /pinpoint-c-agent/ && phpize && ./configure && make && make install
2222
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
2323

24-
RUN COMPOSER_ALLOW_SUPERUSER=1 composer require pinpoint-apm/pinpoint-php-aop:dev-feat-async-rdkafka
24+
RUN COMPOSER_ALLOW_SUPERUSER=1 composer require pinpoint-apm/pinpoint-php-aop:v4.0.1
2525

2626
CMD [ "sh" ,"/workspace/run_all.sh" ]

testapps/cpp/CMakeLists.txt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
66

77
include(FetchContent)
88

9-
# FetchContent_Declare(
10-
# pinpoint
11-
# # URL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/v0.7/pinpoint-common.tar.gz
12-
# URL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/v0.7.0/pinpoint-common.tar.gz
13-
# )
14-
15-
FetchContent_Declare(pinpoint SOURCE_DIR ${PROJECT_SOURCE_DIR}/../../)
16-
17-
FetchContent_GetProperties(pinpoint)
18-
if (NOT pinpoint_POPULATED)
19-
FetchContent_Populate(pinpoint)
20-
add_subdirectory(${pinpoint_SOURCE_DIR}/common ${pinpoint_BINARY_DIR})
21-
endif ()
9+
FetchContent_Declare(
10+
pinpoint
11+
# URL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/v0.7/pinpoint-common.tar.gz
12+
URL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/v0.7.1/pinpoint-common.tar.gz
13+
)
14+
15+
# FetchContent_Declare(pinpoint SOURCE_DIR ${PROJECT_SOURCE_DIR}/../../)
16+
17+
# FetchContent_GetProperties(pinpoint)
18+
# if (NOT pinpoint_POPULATED)
19+
# FetchContent_Populate(pinpoint)
20+
# add_subdirectory(${pinpoint_SOURCE_DIR}/common ${pinpoint_BINARY_DIR})
21+
# endif ()
2222

2323
FetchContent_Declare(
2424
httplib

testapps/flarum/flarum.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ RUN apk update && apk add php8-dev build-base
1414
RUN curl -sL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/latest/download/install_pinpoint_php.sh | sh
1515

1616
COPY testapps/flarum/site.php /flarum/app/site.php
17-
RUN cd /flarum/app/ && composer require -w pinpoint-apm/pinpoint-php-aop:v3.0.1
17+
RUN cd /flarum/app/ && composer require -w pinpoint-apm/pinpoint-php-aop

testapps/laravel/dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ COPY testapps/laravel/example-app /app
1313

1414
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
1515

16-
RUN cd /app && composer update && composer require -w pinpoint-apm/pinpoint-php-aop:v4.x-dev
16+
RUN php --re extension | head -1
17+
18+
RUN cd /app && composer update && composer require -w pinpoint-apm/pinpoint-php-aop
1719
WORKDIR /app
1820
EXPOSE 8000
1921
CMD [ "php" ,"artisan", "serve","--host=0.0.0.0"]

testapps/laravel/example-app/composer.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22
"name": "laravel/laravel",
33
"type": "project",
44
"description": "The Laravel Framework.",
5-
"keywords": ["framework", "laravel"],
5+
"keywords": [
6+
"framework",
7+
"laravel"
8+
],
69
"license": "MIT",
710
"require": {
811
"php": "^7.3|^8.0",
912
"fruitcake/laravel-cors": "^2.0",
1013
"guzzlehttp/guzzle": "^7.0.1",
1114
"laravel/framework": "^8.75",
1215
"laravel/sanctum": "^2.11",
13-
"laravel/tinker": "^2.5",
14-
"pinpoint-apm/pinpoint-php-aop": "v4.x-dev"
16+
"laravel/tinker": "^2.5"
1517
},
1618
"require-dev": {
1719
"facade/ignition": "^2.5",
@@ -60,4 +62,4 @@
6062
},
6163
"minimum-stability": "dev",
6264
"prefer-stable": true
63-
}
65+
}

testapps/php_phpmyadmin/phpmyadmin.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ RUN curl -sL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/latest/do
2020
COPY testapps/php_phpmyadmin/index.php /var/www/html/index.php
2121
## install composer
2222
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
23-
RUN cd /var/www/html/ && composer require -w pinpoint-apm/pinpoint-php-aop:v3.0.1
23+
RUN cd /var/www/html/ && composer require -w pinpoint-apm/pinpoint-php-aop

testapps/php_wordpress/php-wordpress.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ COPY testapps/php_wordpress/wp-config.php /usr/src/wordpress/wp-config.php
1818
# install composer
1919
RUN curl -s https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer
2020
USER www-data
21-
RUN cd /var/www/html/ && composer require -w pinpoint-apm/pinpoint-php-aop:v3.0.1
21+
RUN cd /var/www/html/ && composer require -w pinpoint-apm/pinpoint-php-aop
2222
USER root

testapps/shopware/shopware.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM shyim/shopware:6.4.20-php8.2
22

33
RUN apk update && apk add --virtual build-dependencies build-base git autoconf
44

5-
RUN curl -sL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/latest/download/install_pinpoint_php.sh | sh
5+
RUN curl -sL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/v0.6.6/install_pinpoint_php.sh | sh
66

77
## install composer
88
RUN composer self-update 2.4.4

testapps/thinkphp-php/thinkphp.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ COPY testapps/thinkphp-php/index.php /app/public/index.php
1515

1616
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
1717

18-
RUN cd /app && composer update && composer require pinpoint-apm/pinpoint-php-aop:^3.0.2
18+
RUN cd /app && composer update && composer require pinpoint-apm/pinpoint-php-aop
1919
WORKDIR /app
2020
EXPOSE 8000
2121
CMD [ "php" ,"think", "run" ]

0 commit comments

Comments
 (0)