Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release php-agent #692

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion DOC/C-CPP/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,9 @@ $ ./test_pinpoint.cpp
### Test apps example

- [yhirose/cpp-httplib example](../../testapps/cpp-httplib/readme.md)
- [libevent/libevent example](../../testapps/libevent_http_server/readme.md)
- [libevent/libevent example](../../testapps/libevent_http_server/readme.md)


### Blogs
- [pinpoint-c-agen directly monitor C/C++ applications?](https://github.com/pinpoint-apm/pinpoint-c-agent/issues/690#issuecomment-2421787446)
- [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)
36 changes: 26 additions & 10 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
<email>liu_ming_yi@outlook.com</email>
<active>yes</active>
</lead>
<date>2024-10-20</date>
<date>2024-10-23</date>
<version>
<release>0.6.0</release>
<api>0.6.0</api>
<release>0.6.1</release>
<api>0.6.1</api>
</version>
<stability>
<release>alpha</release>
<api>alpha</api>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="https://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</license>
<notes>
## 0.6.0 2024-10-20
- release asynchronous version
## 0.6.1 2024-10-23
- release asynchronous version https://github.com/pinpoint-apm/pinpoint-c-agent/pull/692
</notes>
<contents>
<dir name="/">
Expand Down Expand Up @@ -110,18 +110,34 @@
<extsrcrelease>
</extsrcrelease>
<changelog>
<release>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<version>
<release>0.6.1</release>
<api>2024-10-23</api>
</version>
<date> 2024-10-23</date>
<notes>
## 0.6.0 2024-10-23 [stable]
- release asynchronous version https://github.com/pinpoint-apm/pinpoint-c-agent/pull/692
</notes>
</release>

<release>
<stability>
<release>alpha</release>
<api>alpha</api>
</stability>
<version>
<release>0.6.0</release>
<api>2024-10-20</api>
<api>2024-10-21</api>
</version>
<date> 2024-10-20</date>
<date> 2024-10-21</date>
<notes>
## 0.6.0 2024-10-20
## 0.6.0 2024-10-21
- release asynchronous version
</notes>
</release>
Expand Down
2 changes: 1 addition & 1 deletion testapps/PHP/php.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN cd /pinpoint-c-agent/ && phpize && ./configure && make && make install
COPY testapps/PHP/php.ini /usr/local/etc/php/conf.d/pinpoint-php-ext.ini

RUN composer create-project --prefer-dist yiisoft/yii2-app-basic /app
RUN composer require -w pinpoint-apm/pinpoint-php-aop:v3.0.2
RUN composer require -w pinpoint-apm/pinpoint-php-aop
RUN chown -R www-data:www-data /app
# Copy index.php
COPY testapps/PHP/index.php /app/web/index.php
Expand Down
80 changes: 80 additions & 0 deletions testapps/SimplePHP/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
## Command

```sh
$ docker compose up simple-php
```

## How to combine kafka producer and consumer together

> Background: some applications use message queue as worker/task dispatcher, but how to address the task dispatcher problems?

Use pinpoint-php agent asynchronous API, it adds some specially header(mask) into message and collects related function call.

![php agent kafka flow](kafka..excalidraw.png)

#### Define a full span into consumer side

> start: kafka message response \
> end: start waiting a new message

![full span](consumer..excalidraw.png)

#### Inside Code

1. Producer side

```php

// run.php
$topic->producev(RD_KAFKA_PARTITION_UA, 0, "I'm Message $i", "key", $headers); // only support message with header(header annotation API)

// kafka interceptor
// lib/Pinpoint/Plugins/SysV2/_rdKafka/rdKafka.php

$producev_on_before = function ($partition, $msgflags, $payload, $key = NULL, $headers = [], $timestamp_ms = NULL, $opaque = NULL) {
pinpoint_start_trace();
...
}

pinpoint_join_cut(
["RdKafka\ProducerTopic", "producev"],
$producev_on_before,
..
);

```

2. Consumer side

```PHP
// kafka_consumer.php
$message = $consumer->consume(120 * 1000);
switch ($message->err) {
case RD_KAFKA_RESP_ERR_NO_ERROR:

$handler = new SimplePHP\MessageHandler();
$handler->handle_message_in_kafka($message);
break;
...

// lib/Pinpoint/Plugins/SysV2/_rdKafka/rdKafka_consumer.php

$rdKafka_consumer_on_before = function ($timeout) use ($interceptor) {
Logger::Inst()->debug("call rdKafka_consumer_on_before");
$depth = pinpoint_get_trace_depth();
switch ($depth) {
case 0:
pinpoint_end_trace();
...}
};

pinpoint_join_cut(
["RdKafka\KafkaConsumer", "consume"],
$rdKafka_consumer_on_before,
...
}

```
#### Inside pinpoint

![alt text](image.png)
Binary file added testapps/SimplePHP/consumer..excalidraw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testapps/SimplePHP/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testapps/SimplePHP/kafka..excalidraw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion testapps/SimplePHP/simplephp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ COPY tests /pinpoint-c-agent/tests
RUN cd /pinpoint-c-agent/ && phpize && ./configure && make && make install
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

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

CMD [ "sh" ,"/workspace/run_all.sh" ]
26 changes: 13 additions & 13 deletions testapps/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

include(FetchContent)

# FetchContent_Declare(
# pinpoint
# # URL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/v0.7/pinpoint-common.tar.gz
# URL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/v0.7.0/pinpoint-common.tar.gz
# )

FetchContent_Declare(pinpoint SOURCE_DIR ${PROJECT_SOURCE_DIR}/../../)

FetchContent_GetProperties(pinpoint)
if (NOT pinpoint_POPULATED)
FetchContent_Populate(pinpoint)
add_subdirectory(${pinpoint_SOURCE_DIR}/common ${pinpoint_BINARY_DIR})
endif ()
FetchContent_Declare(
pinpoint
# URL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/v0.7/pinpoint-common.tar.gz
URL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/v0.7.1/pinpoint-common.tar.gz
)

# FetchContent_Declare(pinpoint SOURCE_DIR ${PROJECT_SOURCE_DIR}/../../)

# FetchContent_GetProperties(pinpoint)
# if (NOT pinpoint_POPULATED)
# FetchContent_Populate(pinpoint)
# add_subdirectory(${pinpoint_SOURCE_DIR}/common ${pinpoint_BINARY_DIR})
# endif ()

FetchContent_Declare(
httplib
Expand Down
2 changes: 1 addition & 1 deletion testapps/flarum/flarum.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ RUN apk update && apk add php8-dev build-base
RUN curl -sL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/latest/download/install_pinpoint_php.sh | sh

COPY testapps/flarum/site.php /flarum/app/site.php
RUN cd /flarum/app/ && composer require -w pinpoint-apm/pinpoint-php-aop:v3.0.1
RUN cd /flarum/app/ && composer require -w pinpoint-apm/pinpoint-php-aop
4 changes: 3 additions & 1 deletion testapps/laravel/dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ COPY testapps/laravel/example-app /app

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

RUN cd /app && composer update && composer require -w pinpoint-apm/pinpoint-php-aop:v4.x-dev
RUN php --re extension | head -1

RUN cd /app && composer update && composer require -w pinpoint-apm/pinpoint-php-aop
WORKDIR /app
EXPOSE 8000
CMD [ "php" ,"artisan", "serve","--host=0.0.0.0"]
10 changes: 6 additions & 4 deletions testapps/laravel/example-app/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.75",
"laravel/sanctum": "^2.11",
"laravel/tinker": "^2.5",
"pinpoint-apm/pinpoint-php-aop": "v4.x-dev"
"laravel/tinker": "^2.5"
},
"require-dev": {
"facade/ignition": "^2.5",
Expand Down Expand Up @@ -60,4 +62,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
2 changes: 1 addition & 1 deletion testapps/php_phpmyadmin/phpmyadmin.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ RUN curl -sL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/latest/do
COPY testapps/php_phpmyadmin/index.php /var/www/html/index.php
## install composer
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
RUN cd /var/www/html/ && composer require -w pinpoint-apm/pinpoint-php-aop:v3.0.1
RUN cd /var/www/html/ && composer require -w pinpoint-apm/pinpoint-php-aop
2 changes: 1 addition & 1 deletion testapps/php_wordpress/php-wordpress.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ COPY testapps/php_wordpress/wp-config.php /usr/src/wordpress/wp-config.php
# install composer
RUN curl -s https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer
USER www-data
RUN cd /var/www/html/ && composer require -w pinpoint-apm/pinpoint-php-aop:v3.0.1
RUN cd /var/www/html/ && composer require -w pinpoint-apm/pinpoint-php-aop
USER root
2 changes: 1 addition & 1 deletion testapps/shopware/shopware.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM shyim/shopware:6.4.20-php8.2

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

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

## install composer
RUN composer self-update 2.4.4
Expand Down
2 changes: 1 addition & 1 deletion testapps/thinkphp-php/thinkphp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ COPY testapps/thinkphp-php/index.php /app/public/index.php

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

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