From addbcf8dce3f259fd56dec8119b4b7ca7a456ee4 Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Thu, 25 Jul 2024 09:24:52 +0800 Subject: [PATCH 01/24] test setup-php --- .github/workflows/main.yml | 339 ++++++++++++++++++++----------------- config.m4 | 2 +- 2 files changed, 185 insertions(+), 156 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 92edefd7..e2a09f93 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,174 +6,203 @@ env: MODULE_PAK: pinpoint_php@${{ github.head_ref || github.ref_name }} jobs: - cpp: - strategy: - matrix: - os: [ubuntu-latest, macos-13] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v2 - - name: actions-setup-cmake - uses: jwlawson/actions-setup-cmake@v1.6 - with: - cmake-version: "3.16.x" - - name: Build agent - run: | - cd common - mkdir -p build - cd build - cmake -DWITH_TEST_CASE=1 -DWITH_CODECOVERAGE=1 -DCMAKE_BUILD_TYPE=Debug .. - make - ./bin/TestCommon - - name: Codecovage - uses: codecov/codecov-action@v4 + # cpp: + # strategy: + # matrix: + # os: [ubuntu-latest, macos-13] + # runs-on: ${{ matrix.os }} + # steps: + # - uses: actions/checkout@v2 + # - name: actions-setup-cmake + # uses: jwlawson/actions-setup-cmake@v1.6 + # with: + # cmake-version: "3.16.x" + # - name: Build agent + # run: | + # cd common + # mkdir -p build + # cd build + # cmake -DWITH_TEST_CASE=1 -DWITH_CODECOVERAGE=1 -DCMAKE_BUILD_TYPE=Debug .. + # make + # ./bin/TestCommon + # - name: Codecovage + # uses: codecov/codecov-action@v4 - cpp-windows: - runs-on: [windows-latest] - steps: - - uses: actions/checkout@v2 + # cpp-windows: + # runs-on: [windows-latest] + # steps: + # - uses: actions/checkout@v2 - - name: powershell allow... - shell: cmd - run: powershell -Command "Set-ExecutionPolicy RemoteSigned -Scope CurrentUser" + # - name: powershell allow... + # shell: cmd + # run: powershell -Command "Set-ExecutionPolicy RemoteSigned -Scope CurrentUser" - - name: Build agent - run: | - cd common - cmake --no-warn-unused-cli -DWITH_TEST_CASE=1 -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -S. -B./build -G "Visual Studio 17 2022" -T host=x86 -A win32 - cmake --build build --target ALL_BUILD --config debug -- - ./build/bin/Debug/TestCommon.exe + # - name: Build agent + # run: | + # cd common + # cmake --no-warn-unused-cli -DWITH_TEST_CASE=1 -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -S. -B./build -G "Visual Studio 17 2022" -T host=x86 -A win32 + # cmake --build build --target ALL_BUILD --config debug -- + # ./build/bin/Debug/TestCommon.exe - memory-leak: - needs: [cpp, cpp-windows] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: actions-setup-cmake - uses: jwlawson/actions-setup-cmake@v1.6 - with: - cmake-version: "3.16.x" - - name: Build agent - run: | - sudo apt update || echo "update failed,but try to overlook it" - sudo apt install -y valgrind -y valgrind - cd common - mkdir -p build - cd build - cmake -DWITH_TEST_CASE=1 -DCMAKE_BUILD_TYPE=Debug .. - make - valgrind --leak-check=full \ - --show-leak-kinds=all \ - --track-origins=yes \ - --verbose \ - --log-file=valgrind-out.txt \ - ./bin/TestCommon - - name: Archive docs - uses: actions/upload-artifact@v3 - with: - name: valgrind-out - path: common/build/valgrind-out.txt + # memory-leak: + # needs: [cpp, cpp-windows] + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v2 + # - name: actions-setup-cmake + # uses: jwlawson/actions-setup-cmake@v1.6 + # with: + # cmake-version: "3.16.x" + # - name: Build agent + # run: | + # sudo apt update || echo "update failed,but try to overlook it" + # sudo apt install -y valgrind -y valgrind + # cd common + # mkdir -p build + # cd build + # cmake -DWITH_TEST_CASE=1 -DCMAKE_BUILD_TYPE=Debug .. + # make + # valgrind --leak-check=full \ + # --show-leak-kinds=all \ + # --track-origins=yes \ + # --verbose \ + # --log-file=valgrind-out.txt \ + # ./bin/TestCommon + # - name: Archive docs + # uses: actions/upload-artifact@v3 + # with: + # name: valgrind-out + # path: common/build/valgrind-out.txt + + # PHP: + # runs-on: ubuntu-latest + # needs: cpp + # strategy: + # matrix: + # php-version: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"] + # steps: + # - uses: actions/checkout@v2 + # with: + # submodules: "true" + # - name: update docker compose + # run: | + # wget "https://github.com/docker/compose/releases/latest/download/docker-compose-linux-x86_64" + # chmod +x docker-compose-linux-x86_64 + # ./docker-compose-linux-x86_64 version + # - name: start test environment + # run: | + # ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" build php-compatible --build-arg PHP_VERSION=${{ matrix.php-version }} + # ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" up php-compatible + # - name: Stop containers + # # if: always() + # run: ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" down php-compatible - PHP: - runs-on: ubuntu-latest - needs: cpp + PHP-Win-2022: + runs-on: windows-2019 strategy: matrix: - php-version: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"] + php-versions: [ "8.3"] + arch: [ "x86" ] steps: - uses: actions/checkout@v2 + - id: setup-php-sdk + uses: php/setup-php-sdk@v0.8 with: - submodules: "true" - - name: update docker compose - run: | - wget "https://github.com/docker/compose/releases/latest/download/docker-compose-linux-x86_64" - chmod +x docker-compose-linux-x86_64 - ./docker-compose-linux-x86_64 version - - name: start test environment - run: | - ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" build php-compatible --build-arg PHP_VERSION=${{ matrix.php-version }} - ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" up php-compatible - - name: Stop containers - # if: always() - run: ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" down php-compatible - - pack_php_module: - runs-on: ubuntu-latest - needs: PHP - steps: - - uses: actions/checkout@v2 - - name: Package pinpoint_php - id: pack - run: | - tar -czf ${{ env.MODULE_PAK }} common/ src/PHP config.m4 tests LICENSE - md5=($(md5sum ${{ env.MODULE_PAK }} )) - PACK_NAME=${{ env.MODULE_PAK }}-${md5}-$(date '+%Y-%m-%d').tar.gz - mv ${{ env.MODULE_PAK }} $PACK_NAME - echo "PACK=$PACK_NAME" >> $GITHUB_OUTPUT - - - uses: actions/upload-artifact@v3 + version: ${{ matrix.php-versions }} + arch: ${{ matrix.arch }} + ts: nts + - uses: ilammy/msvc-dev-cmd@v1 with: - name: ${{ env.MODULE_PAK }} - path: ${{ steps.pack.outputs.PACK }} + arch: ${{ matrix.arch }} + toolset: ${{steps.setup-php-sdk.outputs.toolset}} - Python: - strategy: - matrix: - os: [ubuntu-latest, macos-13] - python-version: ["3.8", "3.9", "3.10", "3.11"] - runs-on: ${{ matrix.os }} - needs: [cpp, cpp-windows] - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - name: run unittest run: | - # ref https://github.com/pypa/setuptools/issues/3198 - pip install -e . - python -m unittest discover -s src/PY/test - python-plugins: - # timeout-minutes: 20 - needs: Python - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - submodules: "true" - - name: update docker compose - run: | - wget "https://github.com/docker/compose/releases/latest/download/docker-compose-linux-x86_64" - chmod +x docker-compose-linux-x86_64 - ./docker-compose-linux-x86_64 version - # run: docker-compose -f "testapps/compose.yaml" build python-plugins - # - name: build python-plugins - - name: start test environment - run: ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" up python-plugins --exit-code-from python-plugins - - name: Stop containers - # if: always() - run: ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" down python-plugins - Collector-agent: - strategy: - matrix: - go-version: [1.18.x] - os: [ubuntu-latest] - runs-on: ${{ matrix.os }} - steps: - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - name: Checkout code - uses: actions/checkout@v2 - with: - submodules: "true" + dir + php -m + php -v + phpize + configure --enable-pinpoint_php --enable-debug-pack + nmake + + + # pack_php_module: + # runs-on: ubuntu-latest + # needs: PHP + # steps: + # - uses: actions/checkout@v2 + # - name: Package pinpoint_php + # id: pack + # run: | + # tar -czf ${{ env.MODULE_PAK }} common/ src/PHP config.m4 tests LICENSE + # md5=($(md5sum ${{ env.MODULE_PAK }} )) + # PACK_NAME=${{ env.MODULE_PAK }}-${md5}-$(date '+%Y-%m-%d').tar.gz + # mv ${{ env.MODULE_PAK }} $PACK_NAME + # echo "PACK=$PACK_NAME" >> $GITHUB_OUTPUT + + # - uses: actions/upload-artifact@v3 + # with: + # name: ${{ env.MODULE_PAK }} + # path: ${{ steps.pack.outputs.PACK }} + + # Python: + # strategy: + # matrix: + # os: [ubuntu-latest, macos-13] + # python-version: ["3.8", "3.9", "3.10", "3.11"] + # runs-on: ${{ matrix.os }} + # needs: [cpp, cpp-windows] + # steps: + # - uses: actions/checkout@v2 + # - uses: actions/setup-python@v2 + # with: + # python-version: ${{ matrix.python-version }} + # - name: run unittest + # run: | + # # ref https://github.com/pypa/setuptools/issues/3198 + # pip install -e . + # python -m unittest discover -s src/PY/test + # python-plugins: + # # timeout-minutes: 20 + # needs: Python + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v2 + # with: + # submodules: "true" + # - name: update docker compose + # run: | + # wget "https://github.com/docker/compose/releases/latest/download/docker-compose-linux-x86_64" + # chmod +x docker-compose-linux-x86_64 + # ./docker-compose-linux-x86_64 version + # # run: docker-compose -f "testapps/compose.yaml" build python-plugins + # # - name: build python-plugins + # - name: start test environment + # run: ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" up python-plugins --exit-code-from python-plugins + # - name: Stop containers + # # if: always() + # run: ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" down python-plugins + # Collector-agent: + # strategy: + # matrix: + # go-version: [1.18.x] + # os: [ubuntu-latest] + # runs-on: ${{ matrix.os }} + # steps: + # - name: Install Go + # uses: actions/setup-go@v2 + # with: + # go-version: ${{ matrix.go-version }} + # - name: Checkout code + # uses: actions/checkout@v2 + # with: + # submodules: "true" - - name: Setup protoc - uses: arduino/setup-protoc@v2.1.0 + # - name: Setup protoc + # uses: arduino/setup-protoc@v2.1.0 - - run: | - go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 - go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2 - export PATH="$PATH:$(go env GOPATH)/bin" - cd collector-agent && make && go test ./... -v + # - run: | + # go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 + # go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2 + # export PATH="$PATH:$(go env GOPATH)/bin" + # cd collector-agent && make && go test ./... -v diff --git a/config.m4 b/config.m4 index 2dbfbff9..b5d8133b 100644 --- a/config.m4 +++ b/config.m4 @@ -28,7 +28,7 @@ if test "$PHP_PINPOINT_PHP" != "no"; then # PINPOINT_COMMON_LIB=PHP_EXT_SRCDIR()/build/lib # echo "----------------------------------------" - EXTRA_PHP_SRCS="src/PHP/pinpoint_php.cpp" + EXTRA_PHP_SRCS="pinpoint_php.cpp" PINPOINT_SRCS="$EXTRA_PHP_SRCS \ common/src/common.cpp \ From 83abab6da997b9586e111f84fd99b599fb407cb1 Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Thu, 25 Jul 2024 09:47:22 +0800 Subject: [PATCH 02/24] Windows (#67) * test on windows * test windows --- .gitignore | 4 +- src/PHP/CHANGES.md => CHANGES-PHP.md | 0 config.w32 | 51 +++++++++++++ .../php_pinpoint_php.h => php_pinpoint_php.h | 1 - src/PHP/pinpoint_php.cpp => pinpoint_php.cpp | 76 +++++++++++-------- 5 files changed, 99 insertions(+), 33 deletions(-) rename src/PHP/CHANGES.md => CHANGES-PHP.md (100%) create mode 100644 config.w32 rename src/PHP/php_pinpoint_php.h => php_pinpoint_php.h (99%) rename src/PHP/pinpoint_php.cpp => pinpoint_php.cpp (97%) diff --git a/.gitignore b/.gitignore index 6d9675c1..d8ebbe4b 100644 --- a/.gitignore +++ b/.gitignore @@ -78,4 +78,6 @@ wheelhouse/ .vs *.dep downloads -testapps/java_call_app/target \ No newline at end of file +testapps/java_call_app/target +x64 +x86 \ No newline at end of file diff --git a/src/PHP/CHANGES.md b/CHANGES-PHP.md similarity index 100% rename from src/PHP/CHANGES.md rename to CHANGES-PHP.md diff --git a/config.w32 b/config.w32 new file mode 100644 index 00000000..9d159df3 --- /dev/null +++ b/config.w32 @@ -0,0 +1,51 @@ +// vim: ft=javascript: + +ARG_ENABLE("pinpoint_php", "whether to enable redis support", "no"); + + +if (PHP_PINPOINT_PHP != "no") { + // var sources = "src/PHP/pinpoint_php.cpp common/src/common.cpp common/src/Logging.cpp common/src/NodePool/TraceNode.cpp common/src/NodePool/PoolManager.cpp common/src/ConnectionPool/TransLayer.cpp common/src/Cache/State.cpp common/src/Cache/Chunk.cpp common/jsoncpp/lib_json/json_writer.cpp common/jsoncpp/lib_json/json_value.cpp common/jsoncpp/lib_json/json_reader.cpp"; + + // CHECK_HEADER_ADD_INCLUDE("json/assertions.h", "CFLAGS", "common/jsoncpp/include"); + // // CHECK_HEADER_ADD_INCLUDE("config.h", "CFLAGS", "src/PHP"); + // CHECK_HEADER_ADD_INCLUDE("common.h", "CFLAGS", "common/include"); + // CHECK_HEADER_ADD_INCLUDE("Context/ContextType.h", "CFLAGS", "common/src"); + // // ADD_FLAG("CFLAGS_PINPOINT_PHP", "/EHsc"); + + // AC_DEFINE("HAVE_PINPOINT_PHP", 1, "Whether you have pinpoint"); + + // EXTENSION("pinpoint_php", sources ,PHP_PINPOINT_PHP_SHARED, '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1'); + + + + // CHECK_HEADER_ADD_INCLUDE("json/assertions.h", "CFLAGS", "common/jsoncpp/include"); + // CHECK_HEADER_ADD_INCLUDE("common.h", "CFLAGS", "common/include"); + // CHECK_HEADER_ADD_INCLUDE("Context/ContextType.h", "CFLAGS", "common/src"); + + EXTENSION("pinpoint_php", "pinpoint_php.cpp", PHP_PINPOINT_PHP_SHARED,'-Icommon/jsoncpp/include -Icommon/include -Icommon/src /EHsc /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1'); + + ADD_SOURCES("common/src/", "\ + common.cpp \ + Logging.cpp \ + ", "pinpoint_php"); + + ADD_SOURCES("common/src/NodePool", "\ + TraceNode.cpp \ + PoolManager.cpp \ + ", "pinpoint_php"); + + ADD_SOURCES("common/src/ConnectionPool", "\ + TransLayer.cpp \ + ", "pinpoint_php"); + + ADD_SOURCES("common/src/Cache", "\ + State.cpp \ + Chunk.cpp \ + ","pinpoint_php") + + ADD_SOURCES( "common/jsoncpp/lib_json", "\ + json_writer.cpp \ + json_value.cpp \ + json_reader.cpp\ + ", "pinpoint_php"); +} diff --git a/src/PHP/php_pinpoint_php.h b/php_pinpoint_php.h similarity index 99% rename from src/PHP/php_pinpoint_php.h rename to php_pinpoint_php.h index 1330b19f..571d40b9 100644 --- a/src/PHP/php_pinpoint_php.h +++ b/php_pinpoint_php.h @@ -16,7 +16,6 @@ #ifndef PHP_PINPOINT_PHP_H #define PHP_PINPOINT_PHP_H -#include "config.h" #include "zend_types.h" extern zend_module_entry pinpoint_php_module_entry; #define phpext_pinpoint_php_ptr &pinpoint_php_module_entry diff --git a/src/PHP/pinpoint_php.cpp b/pinpoint_php.cpp similarity index 97% rename from src/PHP/pinpoint_php.cpp rename to pinpoint_php.cpp index 6730e802..b332c422 100644 --- a/src/PHP/pinpoint_php.cpp +++ b/pinpoint_php.cpp @@ -33,6 +33,10 @@ /* $Id$ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "zend_API.h" #include "zend_string.h" #include "zend_types.h" @@ -40,10 +44,6 @@ #include #include #include -#include -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif // clang-format off #include "php.h" @@ -194,7 +194,8 @@ void (*old_error_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message); #else void (*old_error_cb)(int type, const char *error_filename, - const uint error_lineno, const char *format, va_list args); + const uint32_t error_lineno, const char *format, + va_list args); #endif #define safe_free(x) \ @@ -204,12 +205,12 @@ void (*old_error_cb)(int type, const char *error_filename, } PHP_FUNCTION(_pinpoint_drop_trace) { - long _id = -1; NodeID id = E_ROOT_NODE, cur_id = E_ROOT_NODE; #if PHP_VERSION_ID < 70000 - + size_t _id = -1; zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &_id); #else + zend_long _id = -1; zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &_id); #endif if (_id == -1) { @@ -233,13 +234,13 @@ PHP_FUNCTION(pinpoint_get_this) { } PHP_FUNCTION(_pinpoint_set_context) { - long _id = -1; + std::string key; zval *zvalue; #if PHP_VERSION_ID < 70000 char *zkey = NULL; int zkey_len; - + size_t _id = -1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|l", &zkey, &zkey_len, &zvalue, &_id) == FAILURE) { zend_error(E_ERROR, "key/value required"); @@ -248,6 +249,7 @@ PHP_FUNCTION(_pinpoint_set_context) { key = std::string(zkey, zkey_len); #else + zend_long _id = -1; zend_string *zkey; if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sz|l", &zkey, &zvalue, &_id) == FAILURE) { @@ -343,12 +345,12 @@ PHP_FUNCTION(pinpoint_get_caller_arg) { } PHP_FUNCTION(_pinpoint_get_context) { - long _id = -1; + std::string key; #if PHP_VERSION_ID < 70000 + long _id = -1; char *zkey = NULL; - int zkey_len; - + size_t zkey_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &zkey, &zkey_len, &_id) == FAILURE) { zend_error(E_ERROR, "key/value required"); @@ -358,6 +360,7 @@ PHP_FUNCTION(_pinpoint_get_context) { #else zend_string *zkey; + zend_long _id = -1; if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|l", &zkey, &_id) == FAILURE) { zend_error(E_ERROR, "key/value required"); return; @@ -384,11 +387,12 @@ PHP_FUNCTION(_pinpoint_get_context) { PHP_FUNCTION(_pinpoint_start_time) { RETURN_LONG(pinpoint_start_time()); } PHP_FUNCTION(_pinpoint_start_trace) { - long _id = -1; NodeID id = E_ROOT_NODE, cur_id = E_ROOT_NODE; #if PHP_VERSION_ID < 70000 + long _id = -1; zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &_id); #else + zend_long _id = -1; zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &_id); #endif if (_id == -1) { @@ -416,8 +420,9 @@ void apm_error_cb(int type, const char *_error_filename, const char *error_filename = _error_filename; #else -void apm_error_cb(int type, const char *error_filename, const uint error_lineno, - const char *format, va_list args) { +void apm_error_cb(int type, const char *error_filename, + const uint32_t error_lineno, const char *format, + va_list args) { char *msg; va_list args_copy; #if PHP_VERSION_ID < 80000 @@ -452,13 +457,13 @@ void apm_error_cb(int type, const char *error_filename, const uint error_lineno, } PHP_FUNCTION(_pinpoint_end_trace) { - long _id = -1; NodeID id = E_ROOT_NODE, cur_id = E_ROOT_NODE; #if PHP_VERSION_ID < 70000 - + long _id = -1; zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &_id); #else + zend_long _id = -1; zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &_id); #endif if (_id == -1) { @@ -478,12 +483,12 @@ PHP_FUNCTION(pinpoint_status) { show_status(); } PHP_FUNCTION(_pinpoint_add_clue) { std::string key; std::string value; - long _id = -1; - long _flag = E_LOC_CURRENT; + #if PHP_VERSION_ID < 70000 char *zkey = NULL, *zvalue = NULL; int zkey_len, value_len; - + long _id = -1; + long _flag = E_LOC_CURRENT; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|ll", &zkey, &zkey_len, &zvalue, &value_len, &_id, &_flag) == FAILURE) { @@ -494,8 +499,10 @@ PHP_FUNCTION(_pinpoint_add_clue) { value = std::string(zvalue, value_len); #else - zend_string *zkey; - zend_string *zvalue; + zend_string *zkey = nullptr; + zend_string *zvalue = nullptr; + zend_long _id = -1; + zend_long _flag = E_LOC_CURRENT; if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS|ll", &zkey, &zvalue, &_id, &_flag) == FAILURE) { zend_error(E_ERROR, "pinpoint_add_clue() expects (int, string)."); @@ -513,12 +520,12 @@ PHP_FUNCTION(_pinpoint_unique_id) { RETURN_LONG(generate_unique_id()); } PHP_FUNCTION(_pinpoint_mark_as_error) { std::string msg; std::string fileName; - long _lineno = 0; - long _id = -1; + #if PHP_VERSION_ID < 70000 char *zkey = NULL, *zvalue = NULL; int zkey_len, value_len; - + long _lineno = 0; + long _id = -1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|ll", &zkey, &zkey_len, &zvalue, &value_len, &_lineno, &_id) == FAILURE) { @@ -531,6 +538,8 @@ PHP_FUNCTION(_pinpoint_mark_as_error) { #else zend_string *zkey; zend_string *zvalue; + zend_long _lineno = 0; + zend_long _id = -1; if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS|ll", &zkey, &zvalue, &_lineno, &_id) == FAILURE) { zend_error(E_ERROR, @@ -547,11 +556,11 @@ PHP_FUNCTION(_pinpoint_mark_as_error) { PHP_FUNCTION(_pinpoint_add_clues) { std::string key; std::string value; +#if PHP_VERSION_ID < 70000 long _id = -1; long _flag = E_LOC_CURRENT; -#if PHP_VERSION_ID < 70000 char *zkey = NULL, *zvalue = NULL; - int zkey_len, value_len; + size_t zkey_len, value_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|ll", &zkey, &zkey_len, &zvalue, &value_len, &_id, @@ -564,8 +573,11 @@ PHP_FUNCTION(_pinpoint_add_clues) { #else zend_string *zkey; zend_string *zvalue; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS|ll", &zkey, &zvalue, &_id, - &_flag) == FAILURE) { + zend_long _id = -1; + zend_long _flag = E_LOC_CURRENT; + int ret = zend_parse_parameters(ZEND_NUM_ARGS(), "SS|ll", &zkey, &zvalue, + &_id, &_flag); + if (ret == FAILURE) { zend_error(E_ERROR, "pinpoint_add_clues() expects (int, string)."); return; } @@ -856,7 +868,8 @@ static pp_interceptor_v_t *make_interceptor(zend_string *name, zval *before, zend_function *origin_func) { pp_interceptor_v_t *interceptor = (pp_interceptor_v_t *)malloc(sizeof(pp_interceptor_v_t)); - bzero(interceptor, sizeof(*interceptor)); + // bzero(interceptor, sizeof(*interceptor)); + memset(interceptor, 0, sizeof(*interceptor)); interceptor->name = zend_string_dup(name, 0); interceptor->origin = origin_func->internal_function.handler; interceptor->origin_func = origin_func; @@ -1129,12 +1142,13 @@ PHP_FUNCTION(pinpoint_get_func_ref_args) { #endif PHP_FUNCTION(_pinpoint_trace_limit) { - long timestamp = -1; #if PHP_VERSION_ID < 70000 + long timestamp = -1; zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", ×tamp); #else + zend_long timestamp = -1; zend_parse_parameters(ZEND_NUM_ARGS(), "|l", ×tamp); #endif From 2450f1128e684824729bd163be0390657a79cfc3 Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Thu, 25 Jul 2024 11:44:12 +0800 Subject: [PATCH 03/24] test --- .github/workflows/main.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e2a09f93..c3b01c13 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -102,7 +102,7 @@ jobs: strategy: matrix: php-versions: [ "8.3"] - arch: [ "x86" ] + arch: [ "x86" ,"x64"] steps: - uses: actions/checkout@v2 - id: setup-php-sdk @@ -116,15 +116,26 @@ jobs: arch: ${{ matrix.arch }} toolset: ${{steps.setup-php-sdk.outputs.toolset}} - - name: run unittest + - name: nmake run: | - dir php -m php -v + mkdir output phpize - configure --enable-pinpoint_php --enable-debug-pack + ./configure.bat --enable-pinpoint_php --enable-debug-pack --enable-object-out-dir=output nmake + - name: package + id: pack + shell: bash + run: | + PACK_FULL_NAME=${{ env.MODULE_PAK }}-${{ matrix.php-versions }}-${{ matrix.arch }}.tar.gz + tar --transform 's:.*/::' -czvf ${PACK_FULL_NAME} -T pinpoint_php_files.txt + echo "PACK=$PACK_FULL_NAME" >> $GITHUB_OUTPUT + - uses: actions/upload-artifact@v3 + with: + name: ${{ env.MODULE_PAK }}-${{ matrix.php-versions }}-${{ matrix.arch }} + path: ${{ steps.pack.outputs.PACK }} # pack_php_module: # runs-on: ubuntu-latest @@ -134,7 +145,7 @@ jobs: # - name: Package pinpoint_php # id: pack # run: | - # tar -czf ${{ env.MODULE_PAK }} common/ src/PHP config.m4 tests LICENSE + # tar -czf ${{ env.MODULE_PAK }} common/ config.m4 tests LICENSE pinpoint_php.cpp php_pinpoint_php.h # md5=($(md5sum ${{ env.MODULE_PAK }} )) # PACK_NAME=${{ env.MODULE_PAK }}-${md5}-$(date '+%Y-%m-%d').tar.gz # mv ${{ env.MODULE_PAK }} $PACK_NAME From 245959a15391b93fe3ad9825c1994e33edbd5807 Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Thu, 25 Jul 2024 12:01:28 +0800 Subject: [PATCH 04/24] add pinpoint_php_files.txt --- pinpoint_php_files.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 pinpoint_php_files.txt diff --git a/pinpoint_php_files.txt b/pinpoint_php_files.txt new file mode 100644 index 00000000..7e806231 --- /dev/null +++ b/pinpoint_php_files.txt @@ -0,0 +1,6 @@ +output/Release/php_pinpoint_php.dll +output/Release/php_pinpoint_php.lib +output/Release/php_pinpoint_php.pdb +NOTICE +README.md +CHANGES-PHP.md From cad0c035d67bc5d345ee380d0cffdd4bf6d347f6 Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Thu, 25 Jul 2024 12:14:29 +0800 Subject: [PATCH 05/24] add pinpoint_php_files.txt --- .github/workflows/main.yml | 1 + pinpoint_php_files.txt | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 pinpoint_php_files.txt diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c3b01c13..86607ac4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -124,6 +124,7 @@ jobs: phpize ./configure.bat --enable-pinpoint_php --enable-debug-pack --enable-object-out-dir=output nmake + dir - name: package id: pack shell: bash diff --git a/pinpoint_php_files.txt b/pinpoint_php_files.txt new file mode 100644 index 00000000..7b4a5950 --- /dev/null +++ b/pinpoint_php_files.txt @@ -0,0 +1,6 @@ +output/Release/php_pinpoint_php.dll +output/Release/php_pinpoint_php.lib +output/Release/php_pinpoint_php.pdb +NOTICE +README.md +CHANGES-PHP.md \ No newline at end of file From cb4254c450295edd3f61ac263fa947c68ca745a3 Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:08:57 +0800 Subject: [PATCH 06/24] remove tar --- .github/workflows/main.yml | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 86607ac4..d8868afc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -125,18 +125,25 @@ jobs: ./configure.bat --enable-pinpoint_php --enable-debug-pack --enable-object-out-dir=output nmake dir - - name: package - id: pack - shell: bash - run: | - PACK_FULL_NAME=${{ env.MODULE_PAK }}-${{ matrix.php-versions }}-${{ matrix.arch }}.tar.gz - tar --transform 's:.*/::' -czvf ${PACK_FULL_NAME} -T pinpoint_php_files.txt - echo "PACK=$PACK_FULL_NAME" >> $GITHUB_OUTPUT + # - name: package + # id: pack + # shell: bash + # run: | + + # PACK_FULL_NAME=${{ env.MODULE_PAK }}-${{ matrix.php-versions }}-${{ matrix.arch }}.tar.gz + # tar --transform 's:.*/::' -czvf ${PACK_FULL_NAME} -T pinpoint_php_files.txt + # echo "PACK=$PACK_FULL_NAME" >> $GITHUB_OUTPUT - uses: actions/upload-artifact@v3 with: name: ${{ env.MODULE_PAK }}-${{ matrix.php-versions }}-${{ matrix.arch }} - path: ${{ steps.pack.outputs.PACK }} + path: | + output/Release/php_pinpoint_php.dll + output/Release/php_pinpoint_php.lib + output/Release/php_pinpoint_php.pdb + NOTICE + README.md + CHANGES-PHP.md # pack_php_module: # runs-on: ubuntu-latest From fb5d7638ffddb3b56b397b1b796b8212008721de Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:34:31 +0800 Subject: [PATCH 07/24] update move --- .github/workflows/main.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d8868afc..2802d06f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -134,13 +134,17 @@ jobs: # tar --transform 's:.*/::' -czvf ${PACK_FULL_NAME} -T pinpoint_php_files.txt # echo "PACK=$PACK_FULL_NAME" >> $GITHUB_OUTPUT - - uses: actions/upload-artifact@v3 + - name: package + shell: bash + run: mv output/Release/pinpoint_php.* . + + - uses: actions/upload-artifact@v4 with: name: ${{ env.MODULE_PAK }}-${{ matrix.php-versions }}-${{ matrix.arch }} path: | - output/Release/php_pinpoint_php.dll - output/Release/php_pinpoint_php.lib - output/Release/php_pinpoint_php.pdb + php_pinpoint_php.dll + php_pinpoint_php.lib + php_pinpoint_php.pdb NOTICE README.md CHANGES-PHP.md From 6de931d15683f35eb8c9c958b953bf81b1be21de Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:56:54 +0800 Subject: [PATCH 08/24] use Move-Item --- .github/workflows/main.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2802d06f..182262ff 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -97,7 +97,7 @@ jobs: # # if: always() # run: ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" down php-compatible - PHP-Win-2022: + PHP-Win-2019: runs-on: windows-2019 strategy: matrix: @@ -125,18 +125,9 @@ jobs: ./configure.bat --enable-pinpoint_php --enable-debug-pack --enable-object-out-dir=output nmake dir - # - name: package - # id: pack - # shell: bash - # run: | - - # PACK_FULL_NAME=${{ env.MODULE_PAK }}-${{ matrix.php-versions }}-${{ matrix.arch }}.tar.gz - # tar --transform 's:.*/::' -czvf ${PACK_FULL_NAME} -T pinpoint_php_files.txt - # echo "PACK=$PACK_FULL_NAME" >> $GITHUB_OUTPUT - name: package - shell: bash - run: mv output/Release/pinpoint_php.* . + run: Move-Item -Path output/Release/php_pinpoint_php.* -Destination . - uses: actions/upload-artifact@v4 with: From 8192dc894d3bb0b1db5ed95d0a7af0c39adfb1c1 Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Thu, 25 Jul 2024 15:19:22 +0800 Subject: [PATCH 09/24] enhance for linux --- .github/workflows/main.yml | 4 ++++ .github/workflows/release.yml | 2 +- .gitignore | 2 +- config.m4 | 2 -- config.w32 | 17 ----------------- testapps/PHP/php.dockerfile | 3 ++- testapps/SimplePHP/simplephp.dockerfile | 3 ++- testapps/cachethq/cachethq.dockerfile | 3 ++- testapps/php_compatible.dockerfile | 3 ++- testapps/php_compatible_older.dockerfile | 6 ++++-- 10 files changed, 18 insertions(+), 27 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 182262ff..7714b177 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -139,6 +139,10 @@ jobs: NOTICE README.md CHANGES-PHP.md + LICENSE + retention-days: 7 + overwrite: true + if-no-files-found: error # pack_php_module: # runs-on: ubuntu-latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 811cc94c..8921ba83 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,7 @@ jobs: - name: Package pinpoint_php id: pack run: | - tar -czf ${{ env.MODULE_PAK }} common/ src/PHP config.m4 tests LICENSE + tar -czf ${{ env.MODULE_PAK }} common/ pinpoint_php.cpp php_pinpoint_php.h config.m4 tests LICENSE md5=($(md5sum ${{ env.MODULE_PAK }} )) PACK_NAME=${{ env.MODULE_PAK }}-${md5}-$(date '+%Y-%m-%d').tar.gz mv ${{ env.MODULE_PAK }} $PACK_NAME diff --git a/.gitignore b/.gitignore index d8ebbe4b..202aba9d 100644 --- a/.gitignore +++ b/.gitignore @@ -66,7 +66,7 @@ test.php .libs/ .libs/ aclocal.m4 -src/PHP/pinpoint_php.dep +pinpoint_php.dep collector-agent/collector-agent .cache compile_commands.json diff --git a/config.m4 b/config.m4 index b5d8133b..d102c977 100644 --- a/config.m4 +++ b/config.m4 @@ -16,7 +16,6 @@ if test "$PHP_PINPOINT_PHP" != "no"; then PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/common/jsoncpp/include) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/common/jsoncpp/include) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/common/src) - PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/src/PHP) AC_DEFINE(HAVE_PINPOINT_PHP, 1, [Whether you have pinpoint]) # echo "------Build common libraries------------" @@ -49,5 +48,4 @@ if test "$PHP_PINPOINT_PHP" != "no"; then PINPOINT_PHP_SHARED_LIBADD="$PINPOINT_PHP_SHARED_LIBADD -lrt" PHP_NEW_EXTENSION(pinpoint_php,$PINPOINT_SRCS, $ext_shared) - PHP_ADD_BUILD_DIR($ext_builddir/src/PHP) fi \ No newline at end of file diff --git a/config.w32 b/config.w32 index 9d159df3..62048877 100644 --- a/config.w32 +++ b/config.w32 @@ -4,23 +4,6 @@ ARG_ENABLE("pinpoint_php", "whether to enable redis support", "no"); if (PHP_PINPOINT_PHP != "no") { - // var sources = "src/PHP/pinpoint_php.cpp common/src/common.cpp common/src/Logging.cpp common/src/NodePool/TraceNode.cpp common/src/NodePool/PoolManager.cpp common/src/ConnectionPool/TransLayer.cpp common/src/Cache/State.cpp common/src/Cache/Chunk.cpp common/jsoncpp/lib_json/json_writer.cpp common/jsoncpp/lib_json/json_value.cpp common/jsoncpp/lib_json/json_reader.cpp"; - - // CHECK_HEADER_ADD_INCLUDE("json/assertions.h", "CFLAGS", "common/jsoncpp/include"); - // // CHECK_HEADER_ADD_INCLUDE("config.h", "CFLAGS", "src/PHP"); - // CHECK_HEADER_ADD_INCLUDE("common.h", "CFLAGS", "common/include"); - // CHECK_HEADER_ADD_INCLUDE("Context/ContextType.h", "CFLAGS", "common/src"); - // // ADD_FLAG("CFLAGS_PINPOINT_PHP", "/EHsc"); - - // AC_DEFINE("HAVE_PINPOINT_PHP", 1, "Whether you have pinpoint"); - - // EXTENSION("pinpoint_php", sources ,PHP_PINPOINT_PHP_SHARED, '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1'); - - - - // CHECK_HEADER_ADD_INCLUDE("json/assertions.h", "CFLAGS", "common/jsoncpp/include"); - // CHECK_HEADER_ADD_INCLUDE("common.h", "CFLAGS", "common/include"); - // CHECK_HEADER_ADD_INCLUDE("Context/ContextType.h", "CFLAGS", "common/src"); EXTENSION("pinpoint_php", "pinpoint_php.cpp", PHP_PINPOINT_PHP_SHARED,'-Icommon/jsoncpp/include -Icommon/include -Icommon/src /EHsc /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1'); diff --git a/testapps/PHP/php.dockerfile b/testapps/PHP/php.dockerfile index 4fc60ec5..858a9bbf 100644 --- a/testapps/PHP/php.dockerfile +++ b/testapps/PHP/php.dockerfile @@ -3,7 +3,8 @@ FROM yiisoftware/yii2-php:7.4-fpm-nginx # build ext COPY config.m4 /pinpoint-c-agent/config.m4 -COPY src/PHP /pinpoint-c-agent/src/PHP +COPY pinpoint_php.cpp /pinpoint-c-agent/pinpoint_php.cpp +COPY php_pinpoint_php.h /pinpoint-c-agent/php_pinpoint_php.h COPY common /pinpoint-c-agent/common COPY tests /pinpoint-c-agent/tests diff --git a/testapps/SimplePHP/simplephp.dockerfile b/testapps/SimplePHP/simplephp.dockerfile index 12bb232b..bb843ed8 100644 --- a/testapps/SimplePHP/simplephp.dockerfile +++ b/testapps/SimplePHP/simplephp.dockerfile @@ -14,7 +14,8 @@ RUN cd /tmp/ && git clone https://github.com/phpredis/phpredis.git && cd phpredi RUN cd /tmp/ && git clone https://github.com/php-memcached-dev/php-memcached.git && cd php-memcached && phpize && ./configure && make install RUN cd /tmp/ && git clone https://github.com/krakjoe/apcu.git && cd apcu && phpize && ./configure && make install COPY config.m4 /pinpoint-c-agent/config.m4 -COPY src/PHP /pinpoint-c-agent/src/PHP +COPY pinpoint_php.cpp /pinpoint-c-agent/pinpoint_php.cpp +COPY php_pinpoint_php.h /pinpoint-c-agent/php_pinpoint_php.h COPY common /pinpoint-c-agent/common COPY tests /pinpoint-c-agent/tests diff --git a/testapps/cachethq/cachethq.dockerfile b/testapps/cachethq/cachethq.dockerfile index 8a6e712b..cc6fb2a9 100644 --- a/testapps/cachethq/cachethq.dockerfile +++ b/testapps/cachethq/cachethq.dockerfile @@ -3,7 +3,8 @@ USER root RUN apk update && apk add --virtual build-dependencies build-base gcc wget git php7-dev ENV DB_DRIVER=pgsql COPY config.m4 /pinpoint-c-agent/config.m4 -COPY src/PHP /pinpoint-c-agent/src/PHP +COPY pinpoint_php.cpp /pinpoint-c-agent/pinpoint_php.cpp +COPY php_pinpoint_php.h /pinpoint-c-agent/php_pinpoint_php.h COPY common /pinpoint-c-agent/common COPY testapps/php_wordpress/pinpoint_php.ini /pinpoint-c-agent/pinpoint_php.ini diff --git a/testapps/php_compatible.dockerfile b/testapps/php_compatible.dockerfile index 75db44e5..b949356e 100644 --- a/testapps/php_compatible.dockerfile +++ b/testapps/php_compatible.dockerfile @@ -3,7 +3,8 @@ FROM php:${PHP_VERSION} WORKDIR /pinpoint-c-agent/ RUN apt update && apt install -y valgrind git COPY config.m4 /pinpoint-c-agent/config.m4 -COPY src/PHP /pinpoint-c-agent/src/PHP +COPY pinpoint_php.cpp /pinpoint-c-agent/pinpoint_php.cpp +COPY php_pinpoint_php.h /pinpoint-c-agent/php_pinpoint_php.h COPY common /pinpoint-c-agent/common COPY tests /pinpoint-c-agent/tests ENV NO_INTERACTION=1 diff --git a/testapps/php_compatible_older.dockerfile b/testapps/php_compatible_older.dockerfile index c24e70aa..4b875493 100644 --- a/testapps/php_compatible_older.dockerfile +++ b/testapps/php_compatible_older.dockerfile @@ -3,7 +3,8 @@ FROM php:${PHP_VERSION} WORKDIR /pinpoint-c-agent/ RUN apt update && apt install -y valgrind git COPY config.m4 /pinpoint-c-agent/config.m4 -COPY src/PHP /pinpoint-c-agent/src/PHP +COPY pinpoint_php.cpp /pinpoint-c-agent/pinpoint_php.cpp +COPY php_pinpoint_php.h /pinpoint-c-agent/php_pinpoint_php.h COPY common /pinpoint-c-agent/common COPY tests /pinpoint-c-agent/tests ENV NO_INTERACTION=1 @@ -26,7 +27,8 @@ RUN wget https://www.php.net/distributions/php-${PHP_VERSION}.tar.gz && tar xvf RUN cd php-${PHP_VERSION} && ./configure --build=x86_64-linux-gnu --with-config-file-path=/usr/local/etc/php --with-config-file-scan-dir=/usr/local/etc/php/conf.d --enable-option-checking=fatal --with-mhash --enable-ftp --enable-mbstring --enable-mysqlnd --with-pdo-sqlite=/usr --with-sqlite3=/usr --with-curl --with-openssl --with-zlib --with-libdir=lib/x86_64-linux-gnu build_alias=x86_64-linux-gnu && make -j && make install COPY config.m4 /pinpoint-c-agent/config.m4 -COPY src/PHP /pinpoint-c-agent/src/PHP +COPY pinpoint_php.cpp /pinpoint-c-agent/pinpoint_php.cpp +COPY php_pinpoint_php.h /pinpoint-c-agent/php_pinpoint_php.h COPY common /pinpoint-c-agent/common COPY tests /pinpoint-c-agent/tests ENV NO_INTERACTION=1 From d83da05721f29f2494aae833fb7b08878e06b54d Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Thu, 25 Jul 2024 17:56:14 +0800 Subject: [PATCH 10/24] test case for win32 --- .github/workflows/main.yml | 19 +- .gitignore | 6 +- php_pinpoint_php.h | 10 + tests_win32/add_root_trace.phpt | 36 +++ tests_win32/aop_helper_api.phpt | 194 ++++++++++++ tests_win32/app_info_test.phpt | 16 + tests_win32/drop_trace_test.phpt | 23 ++ tests_win32/mark_as_error.phpt | 26 ++ tests_win32/node_test.phpt | 35 +++ tests_win32/pinpoint_get_caller_arg.phpt | 50 +++ tests_win32/pinpoint_get_this.phpt | 61 ++++ tests_win32/pinpoint_join_cut_curl_7.phpt | 230 ++++++++++++++ tests_win32/pinpoint_join_cut_curl_8.phpt | 232 ++++++++++++++ tests_win32/pinpoint_join_cut_extend_pdo.phpt | 156 ++++++++++ tests_win32/pinpoint_join_cut_mysqli.phpt | 90 ++++++ tests_win32/pinpoint_join_cut_pdo.phpt | 176 +++++++++++ tests_win32/pinpoint_join_cut_pdo_8.phpt | 187 +++++++++++ tests_win32/pinpoint_join_cut_redis.phpt | 293 ++++++++++++++++++ tests_win32/stack_fetal_error.phpt | 62 ++++ tests_win32/trace_api_context_tcp.phpt | 69 +++++ tests_win32/trace_api_test.phpt | 134 ++++++++ tests_win32/trace_api_with_id.phpt | 65 ++++ tests_win32/trace_limit_test-i448.phpt | 48 +++ tests_win32/trace_limit_test.phpt | 23 ++ tests_win32/unique_api_test.phpt | 19 ++ 25 files changed, 2252 insertions(+), 8 deletions(-) create mode 100644 tests_win32/add_root_trace.phpt create mode 100644 tests_win32/aop_helper_api.phpt create mode 100644 tests_win32/app_info_test.phpt create mode 100644 tests_win32/drop_trace_test.phpt create mode 100644 tests_win32/mark_as_error.phpt create mode 100644 tests_win32/node_test.phpt create mode 100644 tests_win32/pinpoint_get_caller_arg.phpt create mode 100644 tests_win32/pinpoint_get_this.phpt create mode 100644 tests_win32/pinpoint_join_cut_curl_7.phpt create mode 100644 tests_win32/pinpoint_join_cut_curl_8.phpt create mode 100644 tests_win32/pinpoint_join_cut_extend_pdo.phpt create mode 100644 tests_win32/pinpoint_join_cut_mysqli.phpt create mode 100644 tests_win32/pinpoint_join_cut_pdo.phpt create mode 100644 tests_win32/pinpoint_join_cut_pdo_8.phpt create mode 100644 tests_win32/pinpoint_join_cut_redis.phpt create mode 100644 tests_win32/stack_fetal_error.phpt create mode 100644 tests_win32/trace_api_context_tcp.phpt create mode 100644 tests_win32/trace_api_test.phpt create mode 100644 tests_win32/trace_api_with_id.phpt create mode 100644 tests_win32/trace_limit_test-i448.phpt create mode 100644 tests_win32/trace_limit_test.phpt create mode 100644 tests_win32/unique_api_test.phpt diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7714b177..23dc9d3d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -101,8 +101,12 @@ jobs: runs-on: windows-2019 strategy: matrix: - php-versions: [ "8.3"] + # php-versions: [ "7.4", "7.3", "7.2","8.0", "8.1", "8.2", "8.3"] + php-versions: [ "7.4"] arch: [ "x86" ,"x64"] + ts: [ "ts", "nts" ] + env: + SKIP_WINDOWS_ACTION: true steps: - uses: actions/checkout@v2 - id: setup-php-sdk @@ -110,28 +114,29 @@ jobs: with: version: ${{ matrix.php-versions }} arch: ${{ matrix.arch }} - ts: nts + ts: ${{ matrix.ts }} - uses: ilammy/msvc-dev-cmd@v1 with: arch: ${{ matrix.arch }} toolset: ${{steps.setup-php-sdk.outputs.toolset}} - - name: nmake + - name: build/test pinpoint_php on windows run: | php -m php -v + where.exe php mkdir output phpize - ./configure.bat --enable-pinpoint_php --enable-debug-pack --enable-object-out-dir=output + ./configure.bat --enable-pinpoint_php --enable-debug-pack --enable-object-out-dir=output --with-prefix=${{steps.setup-php-sdk.outputs.prefix}} nmake - dir + nmake test TESTS=tests_win32 - name: package run: Move-Item -Path output/Release/php_pinpoint_php.* -Destination . - uses: actions/upload-artifact@v4 with: - name: ${{ env.MODULE_PAK }}-${{ matrix.php-versions }}-${{ matrix.arch }} + name: ${{ env.MODULE_PAK }}-php-${{ matrix.php-versions }}-${{ matrix.ts }}-${{ matrix.arch }} path: | php_pinpoint_php.dll php_pinpoint_php.lib @@ -140,7 +145,7 @@ jobs: README.md CHANGES-PHP.md LICENSE - retention-days: 7 + retention-days: 5 overwrite: true if-no-files-found: error diff --git a/.gitignore b/.gitignore index 202aba9d..50e51cc3 100644 --- a/.gitignore +++ b/.gitignore @@ -80,4 +80,8 @@ wheelhouse/ downloads testapps/java_call_app/target x64 -x86 \ No newline at end of file +x86 +output +config.nice.bat +configure.bat +configure.js \ No newline at end of file diff --git a/php_pinpoint_php.h b/php_pinpoint_php.h index 571d40b9..facb8802 100644 --- a/php_pinpoint_php.h +++ b/php_pinpoint_php.h @@ -17,6 +17,11 @@ #define PHP_PINPOINT_PHP_H #include "zend_types.h" +#ifdef __cplusplus + +extern "C" { +#endif // __cplusplus + extern zend_module_entry pinpoint_php_module_entry; #define phpext_pinpoint_php_ptr &pinpoint_php_module_entry @@ -98,4 +103,9 @@ PHP_MSHUTDOWN_FUNCTION(pinpoint_php); PHP_RINIT_FUNCTION(pinpoint_php); PHP_RSHUTDOWN_FUNCTION(pinpoint_php); PHP_MINFO_FUNCTION(pinpoint_php); + +#ifdef __cplusplus +} // extern C +#endif // __cplusplus + #endif /* PHP_PINPOINT_PHP_H */ diff --git a/tests_win32/add_root_trace.phpt b/tests_win32/add_root_trace.phpt new file mode 100644 index 00000000..c38df061 --- /dev/null +++ b/tests_win32/add_root_trace.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test pinpoint_unique_id +--SKIPIF-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=0 +pinpoint_php.UnitTest=true +pinpoint_php.DebugReport=true +--FILE-- + +--INI-- +pinpoint_php.DebugReport=false +--FILE-- +foo('hello pinpoint',1,array('1'=>2,'c'=>3,'e'=>5)); +Foo::static_foo('hello pinpoint',1,array('1'=>2,'c'=>3,'e'=>5)); +$foo->test_none(); +var_dump($foo->return_all("23",1,null)); + +echo "test anonymous \n"; +$name = 'eeliu'; +$nobody = function ($arg) use (&$name) { + var_dump(\pinpoint_get_func_ref_args()); + $name = 'eeliu-01'; + $arg = $arg.$name; + return \pinpoint_get_func_ref_args(); +}; +var_dump($nobody("hello ")); +echo "\n"; + +echo "test pinpoint_get_func_ref_args call in call_user_func_array \n"; + +function foo_ref($a,&$b,&$c) +{ + var_dump(func_get_args()); + $b = 10; + $c = 11; + return array($b,$c); +} + +function aop_foo_ref($a,&$b,&$c) +{ + $args = \pinpoint_get_func_ref_args(); + return call_user_func_array('foo_ref',$args); +} +$b =2; +$c = 12; +var_dump(aop_foo_ref("adf",$b,$c)); +echo "b = $b \n"; +echo "c = $c \n"; + +--EXPECTF-- +array(4) { + [0]=> + &int(100) + [1]=> + int(1) + [2]=> + int(3) + [3]=> + int(4) +} +string(12) "hello php!!!" + +Warning: pinpoint_get_func_ref_args(): Called from the global scope - no function context in %s on line 18 +bool(false) +call __construct +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +array(3) { + [0]=> + string(14) "hello pinpoint" + [1]=> + int(1) + [2]=> + array(3) { + [1]=> + int(2) + ["c"]=> + int(3) + ["e"]=> + int(5) + } +} +array(3) { + [0]=> + string(14) "hello pinpoint" + [1]=> + int(1) + [2]=> + array(3) { + [1]=> + int(2) + ["c"]=> + int(3) + ["e"]=> + int(5) + } +} +array(0) { +} +array(3) { + [0]=> + string(2) "23" + [1]=> + int(1) + [2]=> + NULL +} +test anonymous +array(1) { + [0]=> + string(6) "hello " +} +array(1) { + [0]=> + string(14) "hello eeliu-01" +} + +test pinpoint_get_func_ref_args call in call_user_func_array +array(3) { + [0]=> + string(3) "adf" + [1]=> + int(2) + [2]=> + int(12) +} +array(2) { + [0]=> + int(10) + [1]=> + int(11) +} +b = 10 +c = 11 +call __destruct +array(0) { +} \ No newline at end of file diff --git a/tests_win32/app_info_test.phpt b/tests_win32/app_info_test.phpt new file mode 100644 index 00000000..b5c3fa81 --- /dev/null +++ b/tests_win32/app_info_test.phpt @@ -0,0 +1,16 @@ +--TEST-- +app info +--SKIPIF-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=0 +pinpoint_php.UnitTest=true +pinpoint_php.DebugReport=true +--FILE-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=0 +pinpoint_php.UnitTest=true +pinpoint_php.DebugReport=true +--FILE-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=0 +pinpoint_php.UnitTest=true +;pinpoint_php._limit for internal use. User do not use it +pinpoint_php._limit=yes +pinpoint_php.DebugReport=true +--FILE-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=0 +pinpoint_php.UnitTest=true +pinpoint_php.DebugReport=true +--FILE-- + +--INI-- +pinpoint_php.DebugReport=true +--FILE-- + +--INI-- +pinpoint_php.DebugReport=true +--FILE-- +abc); + var_dump($f->abc_s); + echo " update foo members \n"; + $f->abc = 1234; + $f->abc_s= "hello pinpoint"; + } + }; + + $onBefore(); + } + public $abc = 123; + public $abc_s = "123"; +} + +$f = new Foo(); +$f->output(); +var_dump($f->abc); +var_dump($f->abc_s); +var_dump(pinpoint_get_this()); + +echo "test static method \n"; +class S_Foo +{ + public static $my_static = 'foo'; + + public static function staticValue() { + $f = pinpoint_get_this(); + var_dump($f); + return self::$my_static; + } +} + +$sf = new S_Foo(); +S_Foo::staticValue(); + +--EXPECTF-- +int(123) +string(3) "123" + update foo members +int(1234) +string(14) "hello pinpoint" +[pinpoint] [%d] [%d]pinpoint_get_this: not support, no this +bool(false) +test static method +[pinpoint] [%d] [%d]pinpoint_get_this: not support, no this +bool(false) \ No newline at end of file diff --git a/tests_win32/pinpoint_join_cut_curl_7.phpt b/tests_win32/pinpoint_join_cut_curl_7.phpt new file mode 100644 index 00000000..15b7e499 --- /dev/null +++ b/tests_win32/pinpoint_join_cut_curl_7.phpt @@ -0,0 +1,230 @@ +--TEST-- +pinpoint_php pinpoint_join_cut_cut +--SKIPIF-- +=')) +{ print "skip"; + print "only works in php7"; +} +?> +--INI-- +pinpoint_php.DebugReport=true + +--EXTENSIONS-- +json +curl + +--FILE-- + +--INI-- +pinpoint_php.DebugReport=true + +--EXTENSIONS-- +json + +--FILE-- +=')){ + print "skip"; + print phpversion() . ">= 8.2.0"; +} + +if(getenv('SKIP_WINDOWS_ACTION', true)){ + print "skip"; +} + +?> +--INI-- +pinpoint_php.DebugReport=true +--EXTENSIONS-- +pdo_mysql +--FILE-- +dsn = $dsn; + echo "attached dsn \n"; + } + }, + function ($ret) { + echo "on_end \n"; + }, + function ($e) { + echo "on_exception \n"; + } +); + +$pdo_exec = "PDO::exec"; +_pinpoint_join_cut( + ["PDO", "exec"], + function ($statement) use ($pdo_exec) { + echo "$pdo_exec: on_before: $statement \n"; + }, + function ($ret) use ($pdo_exec) { + echo "$pdo_exec : on_end \n"; + }, + function ($e) use ($pdo_exec) { + echo "on_exception \n"; + } +); + +class MyPDO extends PDO +{ + +} +$dbname = "employees"; +$pdo = new MyPDO("mysql:host=dev-mysql;dbname=$dbname", 'root', 'password'); +$pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); +$pdo->abc = "123"; +$sql = "CREATE table IF NOT EXISTS pdo_test( + ID INT( 11 ) AUTO_INCREMENT PRIMARY KEY, + Name VARCHAR( 250 ) NOT NULL, + AGE tinyint(1) unsigned NOT NULL default '1' );"; +$ret = $pdo->exec($sql); +if ($ret === false) { + echo "create pdo_test failed" . $pdo->errorCode(); +} + +$sql = "INSERT INTO pdo_test (NAME, AGE) +VALUES ('a',1),('b',1),('c',3),('d',1);"; +$ret = $pdo->exec($sql); +var_dump($ret); + +$unbufferedResult = $pdo->query("SELECT * FROM pdo_test"); +foreach ($unbufferedResult as $row) { + var_dump($unbufferedResult); +} + +$sth = $pdo->prepare('SELECT name FROM pdo_test + WHERE AGE = :AGE limit 3'); +/* Names can be prefixed with colons ":" too (optional) */ +$sth->bindValue(':AGE', 1); +$ret = $sth->execute(); +var_dump($ret); +$ret = $sth->fetch(); +var_dump($ret); +$ret = $sth->fetchAll(); +var_dump($ret); +var_dump($pdo->abc); +var_dump($pdo->dsn); +$sql = 'DROP TABLE pdo_test'; +$ret = $pdo->exec($sql); + + +--EXPECTF-- +[pinpoint] [%d] [%d]try to interceptor module(class)/function=pdo:__construct +[pinpoint] [%d] [%d]added interceptor on `module`: pdo::__construct success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=pdo:exec +[pinpoint] [%d] [%d]added interceptor on `module`: pdo::exec success +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:pdo::__construct +on_before: mysql:host=dev-mysql;dbname=employees +attached dsn +[pinpoint] [%d] [%d] call_interceptor_before:pdo::__construct return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +on_end +[pinpoint] [%d] [%d]call_interceptor_end: pdo::__construct +int(4) +object(PDOStatement)#8 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +object(PDOStatement)#8 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +object(PDOStatement)#8 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +object(PDOStatement)#8 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +bool(true) +array(2) { + ["name"]=> + string(1) "a" + [0]=> + string(1) "a" +} +array(2) { + [0]=> + array(2) { + ["name"]=> + string(1) "b" + [0]=> + string(1) "b" + } + [1]=> + array(2) { + ["name"]=> + string(1) "d" + [0]=> + string(1) "d" + } +} +string(3) "123" +string(37) "mysql:host=dev-mysql;dbname=employees" +[pinpoint] [%d] [%d]start free interceptor: pdo::__construct +[pinpoint] [%d] [%d]start free interceptor: pdo::exec \ No newline at end of file diff --git a/tests_win32/pinpoint_join_cut_mysqli.phpt b/tests_win32/pinpoint_join_cut_mysqli.phpt new file mode 100644 index 00000000..3692204e --- /dev/null +++ b/tests_win32/pinpoint_join_cut_mysqli.phpt @@ -0,0 +1,90 @@ +--TEST-- +pinpoint_php pinpoint_join_cut_redis +--SKIPIF-- + +--INI-- +pinpoint_php.DebugReport=true +--EXTENSIONS-- +mysqli +--FILE-- + +host_info; + } + echo "$db_host \n"; +}; + +$on_before_func = function (...$args) { + $mysqli = $args[0]; + $db_host = "localhost"; + if ($mysqli instanceof mysqli) { + $db_host = $mysqli->host_info; + } + echo "$db_host \n"; +}; + +$on_end = function ($ret) { + +}; + +$on_exception = function ($exp) { +}; + + +_pinpoint_join_cut(['mysqli_query'], $on_before_func, $on_end, $on_exception); +_pinpoint_join_cut(['mysqli', 'query'], $on_before, $on_end, $on_exception); + + + +mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); +$mysqli = new mysqli(); + +$mysqli->connect('dev-mysql', "root", "password", "employees", 3306); + +$result = $mysqli->query("SELECT * FROM `dept_emp_latest_date` LIMIT 1000;"); +printf("Select returned %d rows.\n", $result->num_rows); + +$stmt = $mysqli->prepare("SELECT * FROM employees WHERE emp_no=?"); +$id = 10005; +$stmt->bind_param("i", $id); +$stmt->execute(); +$stmt->fetch(); +$stmt->free_result(); +mysqli_query($mysqli, "SELECT * FROM `dept_emp_latest_date` LIMIT 1000;"); + +$s_stmt = mysqli_prepare($mysqli, "SELECT * FROM employees WHERE emp_no=?"); +mysqli_stmt_bind_param($s_stmt, "i", $id); +mysqli_stmt_execute($stmt); + + + + +--EXPECTF-- +[pinpoint] [%d] [%d]try to interceptor function=mysqli_query +[pinpoint] [%d] [%d]added interceptor on `function`: mysqli_query success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=mysqli:query +[pinpoint] [%d] [%d]added interceptor on `module`: mysqli::query success +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:mysqli::query +dev-mysql via TCP/IP +[pinpoint] [%d] [%d] call_interceptor_before:mysqli::query return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +[pinpoint] [%d] [%d]call_interceptor_end: mysqli::query +Select returned 1000 rows. +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:mysqli_query +dev-mysql via TCP/IP +[pinpoint] [%d] [%d] call_interceptor_before:mysqli_query return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +[pinpoint] [%d] [%d]call_interceptor_end: mysqli_query +[pinpoint] [%d] [%d]start free interceptor: mysqli_query +[pinpoint] [%d] [%d]start free interceptor: mysqli::query \ No newline at end of file diff --git a/tests_win32/pinpoint_join_cut_pdo.phpt b/tests_win32/pinpoint_join_cut_pdo.phpt new file mode 100644 index 00000000..385f7dd9 --- /dev/null +++ b/tests_win32/pinpoint_join_cut_pdo.phpt @@ -0,0 +1,176 @@ +--TEST-- +pinpoint_php pinpoint_join_cut_pdo +--SKIPIF-- +=')){ + print "skip"; + print phpversion() . ">= 8.2.0"; +} +if(getenv('SKIP_WINDOWS_ACTION', true)){ + print "skip"; +} + +?> +--INI-- +pinpoint_php.DebugReport=true +--EXTENSIONS-- +pdo_mysql +--FILE-- +dsn = $dsn; + echo "attached dsn \n"; + } + }, + function ($ret) { + echo "on_end \n"; + }, + function ($e) { + echo "on_exception \n"; + } +); +$pdo_exec = "PDO::exec"; +_pinpoint_join_cut( + ["PDO", "exec"], + function ($statement) use ($pdo_exec) { + echo "$pdo_exec: on_before: $statement \n"; + }, + function ($ret) use ($pdo_exec) { + echo "$pdo_exec : on_end \n"; + }, + function ($e) use ($pdo_exec) { + echo "on_exception \n"; + } +); + + +echo "case: pdo() \n"; + +$dbname = "employees"; +$pdo = new PDO("mysql:host=dev-mysql;dbname=$dbname", 'root', 'password'); +$pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); +$pdo->abc = "123"; +$sql = "CREATE table IF NOT EXISTS pdo_test( + ID INT( 11 ) AUTO_INCREMENT PRIMARY KEY, + Name VARCHAR( 250 ) NOT NULL, + AGE tinyint(1) unsigned NOT NULL default '1' );"; +$ret = $pdo->exec($sql); +if ($ret === false) { + echo "create pdo_test failed" . $pdo->errorCode(); +} + +$sql = "INSERT INTO pdo_test (NAME, AGE) +VALUES ('a',1),('b',1),('c',3),('d',1);"; +$ret = $pdo->exec($sql); +var_dump($ret); + +$unbufferedResult = $pdo->query("SELECT * FROM pdo_test"); +foreach ($unbufferedResult as $row) { + var_dump($unbufferedResult); +} + +$sth = $pdo->prepare('SELECT name FROM pdo_test + WHERE AGE = :AGE limit 3'); +/* Names can be prefixed with colons ":" too (optional) */ +$sth->bindValue(':AGE', 1); +$ret = $sth->execute(); +var_dump($ret); +$ret = $sth->fetch(); +var_dump($ret); +$ret = $sth->fetchAll(); +var_dump($ret); +var_dump($pdo->abc); +var_dump($pdo->dsn); +$sql = 'DROP TABLE pdo_test'; +$ret = $pdo->exec($sql); + + +--EXPECTF-- +[pinpoint] [%d] [%d]try to interceptor module(class)/function=pdo:__construct +[pinpoint] [%d] [%d]added interceptor on `module`: pdo::__construct success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=pdo:exec +[pinpoint] [%d] [%d]added interceptor on `module`: pdo::exec success +case: pdo() +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:pdo::__construct +on_before: mysql:host=dev-mysql;dbname=employees +attached dsn +[pinpoint] [%d] [%d] call_interceptor_before:pdo::__construct return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +on_end +[pinpoint] [%d] [%d]call_interceptor_end: pdo::__construct +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:pdo::exec +PDO::exec: on_before: CREATE table IF NOT EXISTS pdo_test( + ID INT( 11 ) AUTO_INCREMENT PRIMARY KEY, + Name VARCHAR( 250 ) NOT NULL, + AGE tinyint(1) unsigned NOT NULL default '1' ); +[pinpoint] [%d] [%d] call_interceptor_before:pdo::exec return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +PDO::exec : on_end +[pinpoint] [%d] [%d]call_interceptor_end: pdo::exec +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:pdo::exec +PDO::exec: on_before: INSERT INTO pdo_test (NAME, AGE) +VALUES ('a',1),('b',1),('c',3),('d',1); +[pinpoint] [%d] [%d] call_interceptor_before:pdo::exec return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +PDO::exec : on_end +[pinpoint] [%d] [%d]call_interceptor_end: pdo::exec +int(4) +object(PDOStatement)#8 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +object(PDOStatement)#8 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +object(PDOStatement)#8 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +object(PDOStatement)#8 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +bool(true) +array(2) { + ["name"]=> + string(1) "a" + [0]=> + string(1) "a" +} +array(2) { + [0]=> + array(2) { + ["name"]=> + string(1) "b" + [0]=> + string(1) "b" + } + [1]=> + array(2) { + ["name"]=> + string(1) "d" + [0]=> + string(1) "d" + } +} +string(3) "123" +string(37) "mysql:host=dev-mysql;dbname=employees" +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:pdo::exec +PDO::exec: on_before: DROP TABLE pdo_test +[pinpoint] [%d] [%d] call_interceptor_before:pdo::exec return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +PDO::exec : on_end +[pinpoint] [%d] [%d]call_interceptor_end: pdo::exec +[pinpoint] [%d] [%d]start free interceptor: pdo::__construct +[pinpoint] [%d] [%d]start free interceptor: pdo::exec \ No newline at end of file diff --git a/tests_win32/pinpoint_join_cut_pdo_8.phpt b/tests_win32/pinpoint_join_cut_pdo_8.phpt new file mode 100644 index 00000000..5c569de6 --- /dev/null +++ b/tests_win32/pinpoint_join_cut_pdo_8.phpt @@ -0,0 +1,187 @@ +--TEST-- +pinpoint_php pinpoint_join_cut_pdo_8 +--SKIPIF-- + +--INI-- +pinpoint_php.DebugReport=true +--EXTENSIONS-- +pdo_mysql + +--FILE-- +setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); +$sql = "CREATE table IF NOT EXISTS pdo_test( + ID INT( 11 ) AUTO_INCREMENT PRIMARY KEY, + Name VARCHAR( 250 ) NOT NULL, + AGE tinyint(1) unsigned NOT NULL default '1' );"; +$ret = $pdo->exec($sql); +if ($ret === false) { + echo "create pdo_test failed" . $pdo->errorCode(); +} + +$sql = "INSERT INTO pdo_test (NAME, AGE) +VALUES ('a',1),('b',1),('c',3),('d',1);"; +$ret = $pdo->exec($sql); +var_dump($ret); + +$unbufferedResult = $pdo->query("SELECT * FROM pdo_test"); +foreach ($unbufferedResult as $row) { + var_dump($unbufferedResult); +} + +$sth = $pdo->prepare('SELECT name FROM pdo_test + WHERE AGE = :AGE limit 3'); +/* Names can be prefixed with colons ":" too (optional) */ +$sth->bindValue(':AGE', 1); +$ret = $sth->execute(); +var_dump($ret); +$ret = $sth->fetch(); +var_dump($ret); +$ret = $sth->fetchAll(); +var_dump($ret); +var_dump($weakMap[$pdo]); +$sql = 'DROP TABLE pdo_test'; +$ret = $pdo->exec($sql); + + + +--EXPECTF-- +[pinpoint] [%d] [%d]try to interceptor module(class)/function=pdo:__construct +[pinpoint] [%d] [%d]added interceptor on `module`: pdo::__construct success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=pdo:exec +[pinpoint] [%d] [%d]added interceptor on `module`: pdo::exec success +case: pdo() +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:pdo::__construct +on_before: mysql:host=dev-mysql;dbname=employees +attached dsn +[pinpoint] [%d] [%d] call_interceptor_before:pdo::__construct return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +on_end +[pinpoint] [%d] [%d]call_interceptor_end: pdo::__construct +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:pdo::exec +PDO::exec: on_before: CREATE table IF NOT EXISTS pdo_test( + ID INT( 11 ) AUTO_INCREMENT PRIMARY KEY, + Name VARCHAR( 250 ) NOT NULL, + AGE tinyint(1) unsigned NOT NULL default '1' ); +mysql:host=dev-mysql;dbname=employees +[pinpoint] [%d] [%d] call_interceptor_before:pdo::exec return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +PDO::exec : on_end +[pinpoint] [%d] [%d]call_interceptor_end: pdo::exec +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:pdo::exec +PDO::exec: on_before: INSERT INTO pdo_test (NAME, AGE) +VALUES ('a',1),('b',1),('c',3),('d',1); +mysql:host=dev-mysql;dbname=employees +[pinpoint] [%d] [%d] call_interceptor_before:pdo::exec return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +PDO::exec : on_end +[pinpoint] [%d] [%d]call_interceptor_end: pdo::exec +int(4) +object(PDOStatement)#9 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +object(PDOStatement)#9 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +object(PDOStatement)#9 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +object(PDOStatement)#9 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +bool(true) +array(2) { + ["name"]=> + string(1) "a" + [0]=> + string(1) "a" +} +array(2) { + [0]=> + array(2) { + ["name"]=> + string(1) "b" + [0]=> + string(1) "b" + } + [1]=> + array(2) { + ["name"]=> + string(1) "d" + [0]=> + string(1) "d" + } +} +string(37) "mysql:host=dev-mysql;dbname=employees" +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:pdo::exec +PDO::exec: on_before: DROP TABLE pdo_test +mysql:host=dev-mysql;dbname=employees +[pinpoint] [%d] [%d] call_interceptor_before:pdo::exec return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +PDO::exec : on_end +[pinpoint] [%d] [%d]call_interceptor_end: pdo::exec +[pinpoint] [%d] [%d]start free interceptor: pdo::__construct +[pinpoint] [%d] [%d]start free interceptor: pdo::exec \ No newline at end of file diff --git a/tests_win32/pinpoint_join_cut_redis.phpt b/tests_win32/pinpoint_join_cut_redis.phpt new file mode 100644 index 00000000..3d94311d --- /dev/null +++ b/tests_win32/pinpoint_join_cut_redis.phpt @@ -0,0 +1,293 @@ +--TEST-- +pinpoint_php pinpoint_join_cut_redis +--SKIPIF-- + + +if(getenv('SKIP_WINDOWS_ACTION', true)){ + print "skip"; +} + +--INI-- +pinpoint_php.DebugReport=true +--EXTENSIONS-- +redis +json +--FILE-- + 'redis', + 'port' => 6379, + 'connectTimeout' => 2.5 +]); +assert($redis->info() !== false); + +echo "case: redis() \n"; +$redis = new Redis(); +$redis->connect('redis', 6379); +assert($redis->info() !== false); + +echo "case: redis() \n"; +$redis = new Redis(); +$redis->pconnect('redis', 6379); +assert($redis->info() !== false); + +echo "case: strings \n"; +$redis = new Redis(); +$redis->pconnect('redis', 6379); +$redis->get("a"); +$redis->set("a", "b"); +$redis->setNx("a", "10"); +$redis->append("ar", "aa"); +$redis->setRange("ar", 0, "bb"); +$redis->get("ar"); +$redis->getRange("ar", 0, 2); +$redis->strlen("ar"); +$redis->getBit("ar", 1); +$redis->setBit("ar", 1, 3); +var_dump($redis->get("ar")); +$redis->mSet(['foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz']); +var_dump($redis->exists('foo', 'bar', 'baz', 'not exists')); +$redis->flushdb(); +--EXPECTF-- +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:info +[pinpoint] [%d] [%d]added interceptor on `module`: redis::info success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:get +[pinpoint] [%d] [%d]added interceptor on `module`: redis::get success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:set +[pinpoint] [%d] [%d]added interceptor on `module`: redis::set success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:setnx +[pinpoint] [%d] [%d]added interceptor on `module`: redis::setnx success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:append +[pinpoint] [%d] [%d]added interceptor on `module`: redis::append success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:getrange +[pinpoint] [%d] [%d]added interceptor on `module`: redis::getrange success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:setrange +[pinpoint] [%d] [%d]added interceptor on `module`: redis::setrange success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:strlen +[pinpoint] [%d] [%d]added interceptor on `module`: redis::strlen success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:getbit +[pinpoint] [%d] [%d]added interceptor on `module`: redis::getbit success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:setbit +[pinpoint] [%d] [%d]added interceptor on `module`: redis::setbit success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:mset +[pinpoint] [%d] [%d]added interceptor on `module`: redis::mset success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:msetnx +[pinpoint] [%d] [%d]added interceptor on `module`: redis::msetnx success +case: redis(xxx) +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::info +Redis::info before: +[pinpoint] [%d] [%d] call_interceptor_before:redis::info return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::info end +[pinpoint] [%d] [%d]call_interceptor_end: redis::info +case: redis() +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::info +Redis::info before: +[pinpoint] [%d] [%d] call_interceptor_before:redis::info return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::info end +[pinpoint] [%d] [%d]call_interceptor_end: redis::info +case: redis() +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::info +Redis::info before: +[pinpoint] [%d] [%d] call_interceptor_before:redis::info return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::info end +[pinpoint] [%d] [%d]call_interceptor_end: redis::info +case: strings +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::get +Redis::get before: a +[pinpoint] [%d] [%d] call_interceptor_before:redis::get return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::get end +[pinpoint] [%d] [%d]call_interceptor_end: redis::get +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::set +Redis::set before: a : b +[pinpoint] [%d] [%d] call_interceptor_before:redis::set return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::set end +[pinpoint] [%d] [%d]call_interceptor_end: redis::set +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::setnx +Redis::setNx before: a : 10 +[pinpoint] [%d] [%d] call_interceptor_before:redis::setnx return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::setNx end +[pinpoint] [%d] [%d]call_interceptor_end: redis::setnx +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::append +Redis::append before: ar : aa +[pinpoint] [%d] [%d] call_interceptor_before:redis::append return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::append end +[pinpoint] [%d] [%d]call_interceptor_end: redis::append +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::setrange +Redis::setRange before: ar +[pinpoint] [%d] [%d] call_interceptor_before:redis::setrange return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::setRange end +[pinpoint] [%d] [%d]call_interceptor_end: redis::setrange +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::get +Redis::get before: ar +[pinpoint] [%d] [%d] call_interceptor_before:redis::get return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::get end +[pinpoint] [%d] [%d]call_interceptor_end: redis::get +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::getrange +Redis::getRange before: ar +[pinpoint] [%d] [%d] call_interceptor_before:redis::getrange return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::getRange end +[pinpoint] [%d] [%d]call_interceptor_end: redis::getrange +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::strlen +Redis::strlen before: ar +[pinpoint] [%d] [%d] call_interceptor_before:redis::strlen return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::strlen end +[pinpoint] [%d] [%d]call_interceptor_end: redis::strlen +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::getbit +Redis::getBit before: ar : 1 +[pinpoint] [%d] [%d] call_interceptor_before:redis::getbit return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::getBit end +[pinpoint] [%d] [%d]call_interceptor_end: redis::getbit +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::setbit +Redis::setBit before: ar +[pinpoint] [%d] [%d] call_interceptor_before:redis::setbit return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::setBit end +[pinpoint] [%d] [%d]call_interceptor_end: redis::setbit +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::get +Redis::get before: ar +[pinpoint] [%d] [%d] call_interceptor_before:redis::get return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::get end +[pinpoint] [%d] [%d]call_interceptor_end: redis::get +string(2) "bb" +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::mset +Redis::mSet before: +[pinpoint] [%d] [%d] call_interceptor_before:redis::mset return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::mSet end +[pinpoint] [%d] [%d]call_interceptor_end: redis::mset +int(3) +[pinpoint] [%d] [%d]start free interceptor: redis::info +[pinpoint] [%d] [%d]start free interceptor: redis::get +[pinpoint] [%d] [%d]start free interceptor: redis::set +[pinpoint] [%d] [%d]start free interceptor: redis::setnx +[pinpoint] [%d] [%d]start free interceptor: redis::append +[pinpoint] [%d] [%d]start free interceptor: redis::getrange +[pinpoint] [%d] [%d]start free interceptor: redis::setrange +[pinpoint] [%d] [%d]start free interceptor: redis::strlen +[pinpoint] [%d] [%d]start free interceptor: redis::getbit +[pinpoint] [%d] [%d]start free interceptor: redis::setbit +[pinpoint] [%d] [%d]start free interceptor: redis::mset +[pinpoint] [%d] [%d]start free interceptor: redis::msetnx \ No newline at end of file diff --git a/tests_win32/stack_fetal_error.phpt b/tests_win32/stack_fetal_error.phpt new file mode 100644 index 00000000..a1c89287 --- /dev/null +++ b/tests_win32/stack_fetal_error.phpt @@ -0,0 +1,62 @@ +--TEST-- +pinpoint_php internal test case [pinpoint_test_main] +--SKIPIF-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=0 +pinpoint_php.UnitTest=true +;pinpoint_php._limit for internal use. User do not use it +pinpoint_php._limit=yes +pinpoint_php.DebugReport=true +--FILE-- + +--INI-- +pinpoint_php.CollectorHost=tcp:127.0.0.1:9999 +pinpoint_php.SendSpanTimeOutMs=0 +pinpoint_php.UnitTest=true +;pinpoint_php._limit for internal use. User do not use it +pinpoint_php._limit=yes +pinpoint_php.DebugReport=true +--FILE-- + +--EXPECTF-- +[pinpoint] [%d] [%d] [0] pinpoint_start child [128] +string(1) "a" +string(1) "b" +string(1) "c" +[pinpoint] [%d] [%d] pinpoint_get_context_key [128] failed with invalid map key, parameters:not exist +bool(false) +[pinpoint] [%d] [%d]this span:({":E":%d,":FT":1500,":S":%d}) +[pinpoint] [%d] [%d]agent try to connect:(127.0.0.1:9999) +[pinpoint] [%d] [%d] [128] pinpoint_end_trace Done! +[pinpoint] [%d] [%d] [0] pinpoint_start child [128] +[pinpoint] [%d] [%d] [128] pinpoint_start child [127] +string(1) "c" +string(1) "b" +string(1) "a" +[pinpoint] [%d] [%d] pinpoint_get_context_key [127] failed with invalid map key, parameters:not exist +bool(false) +[pinpoint] [%d] [%d] [127] pinpoint_end_trace Done! +[pinpoint] [%d] [%d]this span:({":E":%d,":FT":1500,":S":%d,"calls":[{":E":%d,":S":%d}]}) +[pinpoint] [%d] [%d] [128] pinpoint_end_trace Done! +{ + "common_library_version" : "%s", + "pool_free_node" : 128, + "pool_total_node" : 128 +} \ No newline at end of file diff --git a/tests_win32/trace_api_test.phpt b/tests_win32/trace_api_test.phpt new file mode 100644 index 00000000..362d035a --- /dev/null +++ b/tests_win32/trace_api_test.phpt @@ -0,0 +1,134 @@ +--TEST-- +Check call statck +--SKIPIF-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=0 +pinpoint_php.UnitTest=true +;pinpoint_php._limit for internal use. User do not use it +pinpoint_php._limit=yes +pinpoint_php.DebugReport=true +--FILE-- +ouput("234",3432); + usleep(2000); +} + + +echo _pinpoint_start_trace()."\n"; + +_pinpoint_add_clue("name","ouput_234"); +for($x = 0;$x <10;$x++){ + ouput_234(1,3); +} +_pinpoint_add_clue("args",'a,$b'); +_pinpoint_add_clue("ret",'a,$b'); + +echo _pinpoint_end_trace()."\n"; + + +?> +--EXPECTF-- +[pinpoint] [%d] [%d] [0] pinpoint_start child [128] +128 +[pinpoint] [%d] [%d] [128] add clue key:name value:ouput_234 +[pinpoint] [%d] [%d] [128] pinpoint_start child [127] +127 +[pinpoint] [%d] [%d] [127] add clue key:name value:Foo +[pinpoint] [%d] [%d] [127] add clues:1:234,3432 +[pinpoint] [%d] [%d] [127] add clues:2:234 +[pinpoint] [%d] [%d] [127] pinpoint_end_trace Done! +128 +[pinpoint] [%d] [%d] [128] pinpoint_start child [126] +126 +[pinpoint] [%d] [%d] [126] add clue key:name value:Foo +[pinpoint] [%d] [%d] [126] add clues:1:234,3432 +[pinpoint] [%d] [%d] [126] add clues:2:234 +[pinpoint] [%d] [%d] [126] pinpoint_end_trace Done! +128 +[pinpoint] [%d] [%d] [128] pinpoint_start child [125] +125 +[pinpoint] [%d] [%d] [125] add clue key:name value:Foo +[pinpoint] [%d] [%d] [125] add clues:1:234,3432 +[pinpoint] [%d] [%d] [125] add clues:2:234 +[pinpoint] [%d] [%d] [125] pinpoint_end_trace Done! +128 +[pinpoint] [%d] [%d] [128] pinpoint_start child [124] +124 +[pinpoint] [%d] [%d] [124] add clue key:name value:Foo +[pinpoint] [%d] [%d] [124] add clues:1:234,3432 +[pinpoint] [%d] [%d] [124] add clues:2:234 +[pinpoint] [%d] [%d] [124] pinpoint_end_trace Done! +128 +[pinpoint] [%d] [%d] [128] pinpoint_start child [123] +123 +[pinpoint] [%d] [%d] [123] add clue key:name value:Foo +[pinpoint] [%d] [%d] [123] add clues:1:234,3432 +[pinpoint] [%d] [%d] [123] add clues:2:234 +[pinpoint] [%d] [%d] [123] pinpoint_end_trace Done! +128 +[pinpoint] [%d] [%d] [128] pinpoint_start child [122] +122 +[pinpoint] [%d] [%d] [122] add clue key:name value:Foo +[pinpoint] [%d] [%d] [122] add clues:1:234,3432 +[pinpoint] [%d] [%d] [122] add clues:2:234 +[pinpoint] [%d] [%d] [122] pinpoint_end_trace Done! +128 +[pinpoint] [%d] [%d] [128] pinpoint_start child [121] +121 +[pinpoint] [%d] [%d] [121] add clue key:name value:Foo +[pinpoint] [%d] [%d] [121] add clues:1:234,3432 +[pinpoint] [%d] [%d] [121] add clues:2:234 +[pinpoint] [%d] [%d] [121] pinpoint_end_trace Done! +128 +[pinpoint] [%d] [%d] [128] pinpoint_start child [120] +120 +[pinpoint] [%d] [%d] [120] add clue key:name value:Foo +[pinpoint] [%d] [%d] [120] add clues:1:234,3432 +[pinpoint] [%d] [%d] [120] add clues:2:234 +[pinpoint] [%d] [%d] [120] pinpoint_end_trace Done! +128 +[pinpoint] [%d] [%d] [128] pinpoint_start child [119] +119 +[pinpoint] [%d] [%d] [119] add clue key:name value:Foo +[pinpoint] [%d] [%d] [119] add clues:1:234,3432 +[pinpoint] [%d] [%d] [119] add clues:2:234 +[pinpoint] [%d] [%d] [119] pinpoint_end_trace Done! +128 +[pinpoint] [%d] [%d] [128] pinpoint_start child [118] +118 +[pinpoint] [%d] [%d] [118] add clue key:name value:Foo +[pinpoint] [%d] [%d] [118] add clues:1:234,3432 +[pinpoint] [%d] [%d] [118] add clues:2:234 +[pinpoint] [%d] [%d] [118] pinpoint_end_trace Done! +128 +[pinpoint] [%d] [%d] [128] add clue key:args value:a,$b +[pinpoint] [%d] [%d] [128] add clue key:ret value:a,$b +[pinpoint] [%d] [%d]this span:({":E":%d,":FT":1500,":S":%d,"args":"a,$b","calls":[{":E":%d,":S":%d,"clues":["1:234,3432","2:234"],"name":"Foo"},{":E":%d,":S":%d,"clues":["1:234,3432","2:234"],"name":"Foo"},{":E":%d,":S":%d,"clues":["1:234,3432","2:234"],"name":"Foo"},{":E":%d,":S":%d,"clues":["1:234,3432","2:234"],"name":"Foo"},{":E":%d,":S":%d,"clues":["1:234,3432","2:234"],"name":"Foo"},{":E":%d,":S":%d,"clues":["1:234,3432","2:234"],"name":"Foo"},{":E":%d,":S":%d,"clues":["1:234,3432","2:234"],"name":"Foo"},{":E":%d,":S":%d,"clues":["1:234,3432","2:234"],"name":"Foo"},{":E":%d,":S":%d,"clues":["1:234,3432","2:234"],"name":"Foo"},{":E":%d,":S":%d,"clues":["1:234,3432","2:234"],"name":"Foo"}],"name":"ouput_234","ret":"a,$b"}) +[pinpoint] [%d] [%d]agent try to connect:(localhost:10000) +[pinpoint] [%d] [%d] [128] pinpoint_end_trace Done! +0 \ No newline at end of file diff --git a/tests_win32/trace_api_with_id.phpt b/tests_win32/trace_api_with_id.phpt new file mode 100644 index 00000000..627a5626 --- /dev/null +++ b/tests_win32/trace_api_with_id.phpt @@ -0,0 +1,65 @@ +--TEST-- +Test pinpoint_unique_id +--SKIPIF-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=0 +pinpoint_php.UnitTest=true +pinpoint_php.DebugReport=true +--FILE-- +getMessage(),$id); + + do + { + $lastId = _pinpoint_end_trace($lastId); + }while($lastId != 0); + echo "Uncaught exception: " , $exception->getMessage(), "\n"; +} + +set_exception_handler('exception_handler'); + +$id = _pinpoint_start_trace($id); +_pinpoint_add_clue("name","Foo",$id); +$id = _pinpoint_start_trace($id); +_pinpoint_add_clues("name","Foo1",$id); +$id = _pinpoint_start_trace($id); +_pinpoint_add_clue("name","Foo2",$id); +$id = _pinpoint_end_trace($id); +$id = _pinpoint_start_trace($id); +_pinpoint_add_clues("name","Foo3",$id); +_pinpoint_add_clue("name","Foo4",$id); +$id = _pinpoint_end_trace($id); +_pinpoint_add_clues("name","Foo5",$id); +throw new Exception("too heavy, throw it"); +$id = _pinpoint_end_trace($id); +_pinpoint_add_clue("name","Foo",$id); + +$id = _pinpoint_end_trace($id); + +--EXPECTF-- +[pinpoint] [%d] [%d] [0] pinpoint_start child [128] +[pinpoint] [%d] [%d] [128] add clue key:name value:Foo +[pinpoint] [%d] [%d] [128] pinpoint_start child [127] +[pinpoint] [%d] [%d] [127] add clues:name:Foo1 +[pinpoint] [%d] [%d] [127] pinpoint_start child [126] +[pinpoint] [%d] [%d] [126] add clue key:name value:Foo2 +[pinpoint] [%d] [%d] [126] pinpoint_end_trace Done! +[pinpoint] [%d] [%d] [127] pinpoint_start child [125] +[pinpoint] [%d] [%d] [125] add clues:name:Foo3 +[pinpoint] [%d] [%d] [125] add clue key:name value:Foo4 +[pinpoint] [%d] [%d] [125] pinpoint_end_trace Done! +[pinpoint] [%d] [%d] [127] add clues:name:Foo5 +[pinpoint] [%d] [%d] [127] add clue key:EXP value:too heavy, throw it +[pinpoint] [%d] [%d] [127] pinpoint_end_trace Done! +[pinpoint] [%d] [%d]this span:({":E":%d,":FT":1500,":S":%d,"calls":[{":E":%d,":S":%d,"EXP":"too heavy, throw it","calls":[{":E":%d,":S":%d,"name":"Foo2"},{":E":%d,":S":%d,"clues":["name:Foo3"],"name":"Foo4"}],"clues":["name:Foo1","name:Foo5"]}],"name":"Foo"}) +[pinpoint] [%d] [%d]agent try to connect:(localhost:10000) +[pinpoint] [%d] [%d] [128] pinpoint_end_trace Done! +Uncaught exception: too heavy, throw it \ No newline at end of file diff --git a/tests_win32/trace_limit_test-i448.phpt b/tests_win32/trace_limit_test-i448.phpt new file mode 100644 index 00000000..fc062b31 --- /dev/null +++ b/tests_win32/trace_limit_test-i448.phpt @@ -0,0 +1,48 @@ +--TEST-- +Check tracelimit +--SKIPIF-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=200 +pinpoint_php.UnitTest=true +pinpoint_php.TraceLimit=0 +;pinpoint_php._limit for internal use. does not use it +pinpoint_php._limit=yes +pinpoint_php.DebugReport=true +--FILE-- + key, parameters:not exist +bool(false) +[pinpoint] [%d] [%d] [127] pinpoint_end_trace Done! +[pinpoint] [%d] [%d]This span dropped. max_trace_limit:0 current_tick:0 onLine:0 +[pinpoint] [%d] [%d]change current [128] status, before:2,now:4 +[pinpoint] [%d] [%d]current [128] span dropped,due to TRACE_BLOCK +[pinpoint] [%d] [%d] [128] pinpoint_end_trace Done! \ No newline at end of file diff --git a/tests_win32/trace_limit_test.phpt b/tests_win32/trace_limit_test.phpt new file mode 100644 index 00000000..40162c5c --- /dev/null +++ b/tests_win32/trace_limit_test.phpt @@ -0,0 +1,23 @@ +--TEST-- +Check tracelimit +--SKIPIF-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=200 +pinpoint_php.UnitTest=true +pinpoint_php.TraceLimit=2 +;pinpoint_php._limit for internal use. User do not use it +pinpoint_php._limit=yes +pinpoint_php.DebugReport=true +--FILE-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=0 +pinpoint_php.UnitTest=true +pinpoint_php.DebugReport=true +--FILE-- + Date: Fri, 26 Jul 2024 10:56:08 +0800 Subject: [PATCH 11/24] fix header out of order --- .github/workflows/main.yml | 6 ++++-- pinpoint_php.cpp | 21 ++++++++++++--------- tests_win32/add_root_trace.phpt | 2 +- tests_win32/pinpoint_get_caller_arg.phpt | 15 ++++++++++++++- tests_win32/pinpoint_join_cut_curl_7.phpt | 9 ++++++--- tests_win32/pinpoint_join_cut_curl_8.phpt | 6 ++++-- tests_win32/pinpoint_join_cut_mysqli.phpt | 2 +- tests_win32/pinpoint_join_cut_redis.phpt | 3 +-- 8 files changed, 43 insertions(+), 21 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 23dc9d3d..4c0123cc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -129,8 +129,10 @@ jobs: phpize ./configure.bat --enable-pinpoint_php --enable-debug-pack --enable-object-out-dir=output --with-prefix=${{steps.setup-php-sdk.outputs.prefix}} nmake - nmake test TESTS=tests_win32 - + # from https://github.com/php/setup-php-sdk/issues/7 + nmake test TESTS="--show-diff tests_win32" + dir /s output + dir /s php-bin - name: package run: Move-Item -Path output/Release/php_pinpoint_php.* -Destination . diff --git a/pinpoint_php.cpp b/pinpoint_php.cpp index b332c422..98cf404c 100644 --- a/pinpoint_php.cpp +++ b/pinpoint_php.cpp @@ -32,27 +32,28 @@ */ /* $Id$ */ - +// clang-format off #ifdef HAVE_CONFIG_H #include "config.h" #endif - -#include "zend_API.h" -#include "zend_string.h" -#include "zend_types.h" +#include +#include #include #include #include #include +#include -// clang-format off +#include "zend_API.h" +#include "zend_string.h" +#include "zend_types.h" #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" #include "common.h" #include "php_pinpoint_php.h" -#include + // clang-format on #ifdef COMPILE_DL_PINPOINT_PHP #ifdef ZTS @@ -318,12 +319,14 @@ PHP_FUNCTION(pinpoint_get_caller_arg) { if ((zend_ulong)requested_offset >= arg_count) { zend_error(E_WARNING, - "pinpoint_get_caller_arg(): Argument " ZEND_LONG_FMT - " not passed to function", + "pinpoint_get_caller_arg(): Argument " + "%" PRId64 " not passed to function", requested_offset); RETURN_FALSE; } + // ZEND_LONG_FMT + first_extra_arg = ex->func->op_array.num_args; if ((zend_ulong)requested_offset >= first_extra_arg && (ZEND_CALL_NUM_ARGS(ex) > first_extra_arg)) { diff --git a/tests_win32/add_root_trace.phpt b/tests_win32/add_root_trace.phpt index c38df061..be0fbbca 100644 --- a/tests_win32/add_root_trace.phpt +++ b/tests_win32/add_root_trace.phpt @@ -31,6 +31,6 @@ $id = _pinpoint_end_trace($id); [pinpoint] [%d] [%d] [126] add clue key:name value:Foo2 [pinpoint] [%d] [%d] [126] pinpoint_end_trace Done! [pinpoint] [%d] [%d] [127] pinpoint_end_trace Done! -[pinpoint] [%d] [%d]this span:({":E":0,":FT":1500,":S":%d,"calls":[{":E":%d,":S":%d,"calls":[{":E":%d,":S":%d,"name":"Foo2"}],"clues":["name:Foo1"]}],"clues":["global:global_value"],"global":"global_value","name":"Foo"}) +[pinpoint] [%d] [%d]this span:({":E":%d,":FT":1500,":S":%d,"calls":[{":E":%d,":S":%d,"calls":[{":E":%d,":S":%d,"name":"Foo2"}],"clues":["name:Foo1"]}],"clues":["global:global_value"],"global":"global_value","name":"Foo"}) [pinpoint] [%d] [%d]agent try to connect:(localhost:10000) [pinpoint] [%d] [%d] [128] pinpoint_end_trace Done! \ No newline at end of file diff --git a/tests_win32/pinpoint_get_caller_arg.phpt b/tests_win32/pinpoint_get_caller_arg.phpt index 0f244c7d..9dfb10dd 100644 --- a/tests_win32/pinpoint_get_caller_arg.phpt +++ b/tests_win32/pinpoint_get_caller_arg.phpt @@ -1,9 +1,22 @@ --TEST-- pinpoint_php test pinpoint_get_caller_arg --SKIPIF-- - +=')) { print "skip"; print "only works in php7"; } +if(getenv('SKIP_WINDOWS_ACTION', true)){ + print "skip"; +} ?> --INI-- pinpoint_php.DebugReport=true @@ -37,7 +40,7 @@ _pinpoint_join_cut( function ($e) { echo "on_exception \n"; var_dump($e); - }, + } ); _pinpoint_join_cut( @@ -54,7 +57,7 @@ _pinpoint_join_cut( function ($e) { echo "on_exception \n"; var_dump($e); - }, + } ); _pinpoint_join_cut( @@ -86,7 +89,7 @@ _pinpoint_join_cut( function ($e) { echo "on_exception \n"; var_dump($e); - }, + } ); diff --git a/tests_win32/pinpoint_join_cut_curl_8.phpt b/tests_win32/pinpoint_join_cut_curl_8.phpt index c83b773e..ba1726d1 100644 --- a/tests_win32/pinpoint_join_cut_curl_8.phpt +++ b/tests_win32/pinpoint_join_cut_curl_8.phpt @@ -6,10 +6,12 @@ if (!extension_loaded("pinpoint_php")) print "skip"; if (!extension_loaded("curl")) print "skip no curl"; -if (version_compare(phpversion(), '8.0.0', '<')) -{ +if (version_compare(phpversion(), '8.0.0', '<')){ print "skip only works in php8"; } +if(getenv('SKIP_WINDOWS_ACTION', true)){ + print "skip"; +} ?> --INI-- pinpoint_php.DebugReport=true diff --git a/tests_win32/pinpoint_join_cut_mysqli.phpt b/tests_win32/pinpoint_join_cut_mysqli.phpt index 3692204e..f57d505d 100644 --- a/tests_win32/pinpoint_join_cut_mysqli.phpt +++ b/tests_win32/pinpoint_join_cut_mysqli.phpt @@ -1,5 +1,5 @@ --TEST-- -pinpoint_php pinpoint_join_cut_redis +pinpoint_php pinpoint_join_cut_mysqli --SKIPIF-- if(getenv('SKIP_WINDOWS_ACTION', true)){ print "skip"; } - +?> --INI-- pinpoint_php.DebugReport=true --EXTENSIONS-- From 8c290623e09022db4c0d42afcb0e7c34c95527d6 Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Fri, 26 Jul 2024 11:42:29 +0800 Subject: [PATCH 12/24] fix tick++ --- .github/workflows/main.yml | 7 ++++--- common/CHANGES.md | 3 +++ common/CMakeLists.txt | 2 +- common/include/common.h | 2 +- common/src/Cache/State.cpp | 2 +- common/src/Cache/State.h | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4c0123cc..629cdb44 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -131,10 +131,11 @@ jobs: nmake # from https://github.com/php/setup-php-sdk/issues/7 nmake test TESTS="--show-diff tests_win32" - dir /s output - dir /s php-bin + ls -r - name: package - run: Move-Item -Path output/Release/php_pinpoint_php.* -Destination . + run: | + Move-Item -Path output/Release/php_pinpoint_php.* -Destination . -ErrorAction SilentlyContinue + Move-Item -Path output/Release_TS/php_pinpoint_php.* -Destination . -ErrorAction SilentlyContinue - uses: actions/upload-artifact@v4 with: diff --git a/common/CHANGES.md b/common/CHANGES.md index 1f9ef3fd..17f07cbf 100644 --- a/common/CHANGES.md +++ b/common/CHANGES.md @@ -1,3 +1,6 @@ +## v0.5.2 2024-07-26 +- fix `tick++` + ## v0.5.1 2024-05-07 - fix logging bug - add EXP_V2 protocol 2024-04-30 diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 28278906..cfe0b515 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.13) -project(pinpoint VERSION 0.5.1 DESCRIPTION "pinpoint common library") +project(pinpoint VERSION 0.5.2 DESCRIPTION "pinpoint common library") set(CMAKE_CXX_STANDARD 11) diff --git a/common/include/common.h b/common/include/common.h index dd71d558..463ea65a 100644 --- a/common/include/common.h +++ b/common/include/common.h @@ -73,7 +73,7 @@ static const NodeID E_ROOT_NODE = 0; static const E_NODE_LOC E_LOC_CURRENT = 0x0; static const E_NODE_LOC E_LOC_ROOT = 0x1; -#define PINPOINT_C_AGENT_API_VERSION "0.5.0" +#define PINPOINT_C_AGENT_API_VERSION "0.5.2" /** * @brief change logs diff --git a/common/src/Cache/State.cpp b/common/src/Cache/State.cpp index dbeab245..8421e001 100644 --- a/common/src/Cache/State.cpp +++ b/common/src/Cache/State.cpp @@ -46,7 +46,7 @@ bool ProcessState::CheckTraceLimit(int64_t timestamp) { return false; BLOCK: pp_trace("This span dropped. max_trace_limit:%ld current_tick:%lld onLine:%d", trace_limit_, - tick_, this->IsReady() ? (1) : (0)); + tick_.load(), this->IsReady() ? (1) : (0)); return true; } diff --git a/common/src/Cache/State.h b/common/src/Cache/State.h index 6ede83ac..222ee80c 100644 --- a/common/src/Cache/State.h +++ b/common/src/Cache/State.h @@ -45,7 +45,7 @@ class ProcessState : public State { virtual ~ProcessState() = default; private: - int64_t tick_ = {0}; + std::atomic tick_ = {0}; std::time_t timestamp_ = {0}; // default is the unix time in ms uint64_t starttime_; From 1f7e0347a6af66f86f996530404ab5a369a875be Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Fri, 26 Jul 2024 15:38:35 +0800 Subject: [PATCH 13/24] support x86 --- .github/workflows/main.yml | 9 ++++++--- common/src/Cache/State.cpp | 17 ++++++++++------- common/src/Cache/State.h | 4 ++-- common/src/NodePool/TraceNode.cpp | 4 ++-- common/src/NodePool/TraceNode.h | 3 ++- common/src/common.cpp | 3 ++- pinpoint_php.cpp | 24 +++++++++++++++--------- tests_win32/app_info_test.phpt | 2 +- tests_win32/pinpoint_join_cut_redis.phpt | 4 ++++ tests_win32/stack_fetal_error.phpt | 2 +- 10 files changed, 45 insertions(+), 27 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 629cdb44..5e33fe00 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -101,7 +101,7 @@ jobs: runs-on: windows-2019 strategy: matrix: - # php-versions: [ "7.4", "7.3", "7.2","8.0", "8.1", "8.2", "8.3"] + # php-versions: [ "7.4", "7.3", "7.2","7.1","8.0", "8.1", "8.2", "8.3"] php-versions: [ "7.4"] arch: [ "x86" ,"x64"] ts: [ "ts", "nts" ] @@ -120,7 +120,7 @@ jobs: arch: ${{ matrix.arch }} toolset: ${{steps.setup-php-sdk.outputs.toolset}} - - name: build/test pinpoint_php on windows + - name: build pinpoint_php on windows run: | php -m php -v @@ -129,9 +129,12 @@ jobs: phpize ./configure.bat --enable-pinpoint_php --enable-debug-pack --enable-object-out-dir=output --with-prefix=${{steps.setup-php-sdk.outputs.prefix}} nmake + + - name: test pinpoint_php on windows + run: | # from https://github.com/php/setup-php-sdk/issues/7 nmake test TESTS="--show-diff tests_win32" - ls -r + - name: package run: | Move-Item -Path output/Release/php_pinpoint_php.* -Destination . -ErrorAction SilentlyContinue diff --git a/common/src/Cache/State.cpp b/common/src/Cache/State.cpp index 8421e001..83d28023 100644 --- a/common/src/Cache/State.cpp +++ b/common/src/Cache/State.cpp @@ -17,6 +17,8 @@ #include "State.h" #include "common.h" #include "header.h" +#include /* For PRIu64 */ + namespace PP { ProcessState::ProcessState(int64_t trace_limit) : starttime_(get_unix_time_ms()), trace_limit_(trace_limit) {} @@ -30,23 +32,24 @@ void ProcessState::SetStartTime(uint64_t start_time) { } bool ProcessState::CheckTraceLimit(int64_t timestamp) { - time_t now = (timestamp != -1) ? (timestamp) : (std::time(NULL)); + std::time_t now = (timestamp != -1) ? (static_cast(timestamp)) : (std::time(NULL)); if (trace_limit_ == -1) { return false; } else if (trace_limit_ == 0) { - goto BLOCK; + goto LIMITED; } if (timestamp_ != now) { timestamp_ = now; tick_ = 0; - } else if (++tick_ >= trace_limit_) { - goto BLOCK; + } else if (tick_ >= trace_limit_) { + goto LIMITED; } + tick_++; return false; -BLOCK: - pp_trace("This span dropped. max_trace_limit:%ld current_tick:%lld onLine:%d", trace_limit_, - tick_.load(), this->IsReady() ? (1) : (0)); +LIMITED: + pp_trace("This span dropped. max_trace_limit:%" PRIu64 " current_tick:%" PRIu64 " onLine:%d", + trace_limit_, tick_.load(), (this->IsReady() ? (1) : (0))); return true; } diff --git a/common/src/Cache/State.h b/common/src/Cache/State.h index 222ee80c..200bc73b 100644 --- a/common/src/Cache/State.h +++ b/common/src/Cache/State.h @@ -45,11 +45,11 @@ class ProcessState : public State { virtual ~ProcessState() = default; private: - std::atomic tick_ = {0}; + std::atomic tick_ = {0}; std::time_t timestamp_ = {0}; // default is the unix time in ms uint64_t starttime_; - int64_t trace_limit_; + const int64_t trace_limit_; std::atomic uuid_ = {0}; bool ready_ = {false}; }; diff --git a/common/src/NodePool/TraceNode.cpp b/common/src/NodePool/TraceNode.cpp index b085e627..50317f7d 100644 --- a/common/src/NodePool/TraceNode.cpp +++ b/common/src/NodePool/TraceNode.cpp @@ -102,8 +102,8 @@ void TraceNode::parseOpt(std::string key, std::string value) { if (key == "TraceMinTimeMs") { int64_t min = std::stoll(value); auto cb = [=]() -> bool { - pp_trace("checkOpt: [%d] TraceMinTimeMs:%ld cumulative_time:%lu", this->id_, min, - this->cumulative_time); + pp_trace("checkOpt: [%d] TraceMinTimeMs:%" PRIu64 " cumulative_time:%" PRIu64 "", this->id_, + min, this->cumulative_time); if ((int64_t)this->cumulative_time >= min) return true; return false; diff --git a/common/src/NodePool/TraceNode.h b/common/src/NodePool/TraceNode.h index 4646440c..ce68b040 100644 --- a/common/src/NodePool/TraceNode.h +++ b/common/src/NodePool/TraceNode.h @@ -251,7 +251,7 @@ class TraceNode { "root_start_time:%" PRIu64 ",set_exp_:%d \n" "ref_count_:%d \n" "_value:%s \n" - "context_ size:%" PRIu64 ",_endTraceCallback:%" PRIu64 " \n", + "context_ size:%zu,_endTraceCallback:%zu \n ", (int)this->sibling_id_, (int)this->last_child_id_, (int)this->parent_id_, (int)this->root_id_, (int)this->id_, this->start_time, this->fetal_error_time, this->limit, this->cumulative_time, this->root_start_time, this->set_exp_, @@ -288,6 +288,7 @@ class WrapperTraceNodePtr { WrapperTraceNodePtr() = delete; WrapperTraceNodePtr(const WrapperTraceNodePtr& other) = delete; WrapperTraceNodePtr(WrapperTraceNodePtr& other) = delete; + WrapperTraceNodePtr(WrapperTraceNodePtr&& other) : traceNode_(other.traceNode_) { traceNode_.addRef(); } diff --git a/common/src/common.cpp b/common/src/common.cpp index 04666149..6782dd4f 100644 --- a/common/src/common.cpp +++ b/common/src/common.cpp @@ -167,7 +167,8 @@ class Agent { } else if (w_trace->limit & E_TRACE_BLOCK) { pp_trace("current [%d] span dropped,due to TRACE_BLOCK", w_trace->getId()); } else { - pp_trace("current [%d] span dropped,due to limit=%ld", w_trace->getId(), w_trace->limit); + pp_trace("current [%d] span dropped,due to limit=%" PRIu64 "", w_trace->getId(), + w_trace->limit); } } else { w_trace->EndTimer(); diff --git a/pinpoint_php.cpp b/pinpoint_php.cpp index 98cf404c..7fc6857b 100644 --- a/pinpoint_php.cpp +++ b/pinpoint_php.cpp @@ -387,7 +387,9 @@ PHP_FUNCTION(_pinpoint_get_context) { } } -PHP_FUNCTION(_pinpoint_start_time) { RETURN_LONG(pinpoint_start_time()); } +PHP_FUNCTION(_pinpoint_start_time) { + RETURN_DOUBLE(static_cast(pinpoint_start_time())); +} PHP_FUNCTION(_pinpoint_start_trace) { NodeID id = E_ROOT_NODE, cur_id = E_ROOT_NODE; @@ -518,7 +520,9 @@ PHP_FUNCTION(_pinpoint_add_clue) { pinpoint_add_clue(Id, key.c_str(), value.c_str(), (E_NODE_LOC)_flag); } -PHP_FUNCTION(_pinpoint_unique_id) { RETURN_LONG(generate_unique_id()); } +PHP_FUNCTION(_pinpoint_unique_id) { + RETURN_DOUBLE(static_cast(generate_unique_id())); +} PHP_FUNCTION(_pinpoint_mark_as_error) { std::string msg; @@ -606,7 +610,9 @@ static inline zend_string *merge_pp_style_name(zend_string *scope, return zend_string_tolower(func); } } + #if PHP_MAJOR_VERSION == 8 and PHP_MINOR_VERSION >= 2 + // ref from php-8.2.19/ext/standard/var.c:137 static zval *zend_array_index(zval *ar, int index) { HashTable *__ht = Z_ARRVAL_P(ar); @@ -1145,19 +1151,19 @@ PHP_FUNCTION(pinpoint_get_func_ref_args) { #endif PHP_FUNCTION(_pinpoint_trace_limit) { - + // getchar(); + double timestamp = -1; #if PHP_VERSION_ID < 70000 - long timestamp = -1; - zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", ×tamp); + zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|d", ×tamp); #else - zend_long timestamp = -1; - zend_parse_parameters(ZEND_NUM_ARGS(), "|l", ×tamp); + zend_parse_parameters(ZEND_NUM_ARGS(), "|d", ×tamp); #endif - timestamp = (timestamp == -1) ? (time(NULL)) : (timestamp); + int64_t timestamp_64 = + (timestamp == -1) ? (time(NULL)) : (static_cast(timestamp)); - if (check_trace_limit(timestamp) == 1) { + if (check_trace_limit(timestamp_64) == 1) { RETURN_TRUE; } else { RETURN_FALSE; diff --git a/tests_win32/app_info_test.phpt b/tests_win32/app_info_test.phpt index b5c3fa81..7c7e1817 100644 --- a/tests_win32/app_info_test.phpt +++ b/tests_win32/app_info_test.phpt @@ -12,5 +12,5 @@ pinpoint_php.DebugReport=true var_dump(_pinpoint_start_time()); var_dump("APP".'^'.strval(_pinpoint_start_time()).'^'.strval(_pinpoint_unique_id())); --EXPECTF-- -int(%d) +float(%d) string(%d) "APP^%d^%d" \ No newline at end of file diff --git a/tests_win32/pinpoint_join_cut_redis.phpt b/tests_win32/pinpoint_join_cut_redis.phpt index 04905bda..2ec54f32 100644 --- a/tests_win32/pinpoint_join_cut_redis.phpt +++ b/tests_win32/pinpoint_join_cut_redis.phpt @@ -4,6 +4,10 @@ pinpoint_php pinpoint_join_cut_redis Date: Fri, 26 Jul 2024 15:46:17 +0800 Subject: [PATCH 14/24] release test --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5e33fe00..a75db049 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -101,8 +101,8 @@ jobs: runs-on: windows-2019 strategy: matrix: - # php-versions: [ "7.4", "7.3", "7.2","7.1","8.0", "8.1", "8.2", "8.3"] - php-versions: [ "7.4"] + php-versions: [ "7.4", "7.3", "7.2","7.1","8.0", "8.1", "8.2", "8.3"] + # php-versions: [ "7.4"] arch: [ "x86" ,"x64"] ts: [ "ts", "nts" ] env: From b00d4d7767b9f222a29084d8f3dc7370e11791e4 Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Fri, 26 Jul 2024 16:19:05 +0800 Subject: [PATCH 15/24] remove "and" problem in windows --- pinpoint_php.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pinpoint_php.cpp b/pinpoint_php.cpp index 7fc6857b..0e1d8392 100644 --- a/pinpoint_php.cpp +++ b/pinpoint_php.cpp @@ -611,7 +611,7 @@ static inline zend_string *merge_pp_style_name(zend_string *scope, } } -#if PHP_MAJOR_VERSION == 8 and PHP_MINOR_VERSION >= 2 +#if (PHP_MAJOR_VERSION == 8 && PHP_MINOR_VERSION >= 2) // ref from php-8.2.19/ext/standard/var.c:137 static zval *zend_array_index(zval *ar, int index) { @@ -675,7 +675,7 @@ get_pp_style_function_name(zend_execute_data *execute_data) { zend_string *scope_name; if (func->common.scope) { scope_name = func->common.scope->name; -#if PHP_MAJOR_VERSION == 7 and PHP_MINOR_VERSION <= 2 +#if PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION <= 2 } else if (object->handlers->get_class_name == std_object_handlers.get_class_name) { #else From 57a6e19f06367536008bc3b7c01d914de1387685 Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Fri, 26 Jul 2024 18:09:25 +0800 Subject: [PATCH 16/24] fix LNK2001 --- config.w32 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config.w32 b/config.w32 index 62048877..9436917c 100644 --- a/config.w32 +++ b/config.w32 @@ -5,7 +5,8 @@ ARG_ENABLE("pinpoint_php", "whether to enable redis support", "no"); if (PHP_PINPOINT_PHP != "no") { - EXTENSION("pinpoint_php", "pinpoint_php.cpp", PHP_PINPOINT_PHP_SHARED,'-Icommon/jsoncpp/include -Icommon/include -Icommon/src /EHsc /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1'); + // EXTENSION("pinpoint_php", "pinpoint_php.cpp", PHP_PINPOINT_PHP_SHARED,'-Icommon/jsoncpp/include -Icommon/include -Icommon/src /EHsc /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1'); + EXTENSION("pinpoint_php", "pinpoint_php.cpp", PHP_PINPOINT_PHP_SHARED,'-Icommon/jsoncpp/include -Icommon/include -Icommon/src /EHsc'); ADD_SOURCES("common/src/", "\ common.cpp \ From 1217dd6e3f81fbcae4bf0df8732ac1caf644fc71 Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Mon, 29 Jul 2024 16:54:29 +0800 Subject: [PATCH 17/24] test package --- .github/workflows/main.yml | 4 +- package.xml | 121 +++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 package.xml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a75db049..dee6a886 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,7 +3,7 @@ name: CI on: [pull_request, workflow_dispatch, push] env: - MODULE_PAK: pinpoint_php@${{ github.head_ref || github.ref_name }} + MODULE_PAK: pinpoint_php-${{ github.head_ref || github.ref_name }} jobs: # cpp: @@ -142,7 +142,7 @@ jobs: - uses: actions/upload-artifact@v4 with: - name: ${{ env.MODULE_PAK }}-php-${{ matrix.php-versions }}-${{ matrix.ts }}-${{ matrix.arch }} + name: ${{ env.MODULE_PAK }}-${{ matrix.php-versions }}-${{ matrix.ts }}-${{steps.setup-php-sdk.outputs.vs}}-${{ matrix.arch }} path: | php_pinpoint_php.dll php_pinpoint_php.lib diff --git a/package.xml b/package.xml new file mode 100644 index 00000000..686c6c21 --- /dev/null +++ b/package.xml @@ -0,0 +1,121 @@ + + + pinpoint_php + pecl.php.net + PHP extension for pinpoint-apm + + This extension provides an API pinpoint-apm and built-in function auto-injection + + + Jason Mile + eeliu + liu_ming_yi@outlook.com + yes + + 2024-07-29 + + 0.5.2 + 0.5.2 + + + stable + stable + + PHP + + https://github.com/pinpoint-apm/pinpoint-c-agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 7.1.0 + + + 1.4.0b1 + + + + pinpoint_php + + + + + stablestable + 0.5.20.5.2 + 2024-07-29 + + https://github.com/pinpoint-apm/pinpoint-c-agent/releases/tag/v0.6.0 + + + + + \ No newline at end of file From e066b3eac82a2b36d13121c40bcb8dbeaf8e6c3a Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Tue, 30 Jul 2024 10:55:52 +0800 Subject: [PATCH 18/24] update license Apache 2.0 --- composer.json | 15 +++++++++++++++ package.xml | 7 +++++-- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 composer.json diff --git a/composer.json b/composer.json new file mode 100644 index 00000000..a28350b7 --- /dev/null +++ b/composer.json @@ -0,0 +1,15 @@ +{ + "name": "pinpoint_php", + "version": "0.5.2", + "type": "extension", + "license": [ + "Apache License 2.0" + ], + "authors": [ + { + "name": "Jason Mile", + "email": "liu_ming_yi@outlook.com" + } + ], + "description": "PHP extension for pinpoint-apm" +} \ No newline at end of file diff --git a/package.xml b/package.xml index 686c6c21..23193087 100644 --- a/package.xml +++ b/package.xml @@ -24,7 +24,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> stable stable - PHP + Apache License 2.0 https://github.com/pinpoint-apm/pinpoint-c-agent @@ -113,7 +113,10 @@ http://pear.php.net/dtd/package-2.0.xsd"> 0.5.20.5.2 2024-07-29 - https://github.com/pinpoint-apm/pinpoint-c-agent/releases/tag/v0.6.0 + ## What's Changed + - add pinpoint_get_caller_arg + + **Full Changelog**: https://github.com/pinpoint-apm/pinpoint-c-agent/compare/v0.5.0...v0.6.0 From 1b0b9d4e1354701e2b19c10c5e4d304f346fa4fe Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:27:29 +0800 Subject: [PATCH 19/24] support macOs (#68) * support macOs - build problems - CI * support pecl install * add dl_cd_pinpoint --- .github/workflows/main.yml | 403 ++++++++++-------- common/CHANGES.md | 3 + common/CMakeLists.txt | 2 +- common/include/common.h | 2 +- common/src/common.cpp | 2 + config.m4 | 27 +- package.xml | 18 +- tests_macos/add_root_trace.phpt | 36 ++ tests_macos/aop_helper_api.phpt | 194 +++++++++ tests_macos/app_info_test.phpt | 16 + tests_macos/drop_trace_test.phpt | 23 + tests_macos/mark_as_error.phpt | 26 ++ tests_macos/node_test.phpt | 35 ++ tests_macos/pinpoint_get_caller_arg.phpt | 63 +++ tests_macos/pinpoint_get_this.phpt | 61 +++ tests_macos/pinpoint_join_cut_curl_7.phpt | 233 ++++++++++ tests_macos/pinpoint_join_cut_curl_8.phpt | 234 ++++++++++ tests_macos/pinpoint_join_cut_extend_pdo.phpt | 156 +++++++ tests_macos/pinpoint_join_cut_mysqli.phpt | 90 ++++ tests_macos/pinpoint_join_cut_pdo.phpt | 176 ++++++++ tests_macos/pinpoint_join_cut_pdo_8.phpt | 187 ++++++++ tests_macos/pinpoint_join_cut_redis.phpt | 295 +++++++++++++ tests_macos/stack_fetal_error.phpt | 62 +++ tests_macos/trace_api_context_tcp.phpt | 70 +++ tests_macos/trace_api_test.phpt | 134 ++++++ tests_macos/trace_api_with_id.phpt | 65 +++ tests_macos/trace_limit_test-i448.phpt | 48 +++ tests_macos/trace_limit_test.phpt | 23 + tests_macos/unique_api_test.phpt | 19 + 29 files changed, 2510 insertions(+), 193 deletions(-) create mode 100644 tests_macos/add_root_trace.phpt create mode 100644 tests_macos/aop_helper_api.phpt create mode 100644 tests_macos/app_info_test.phpt create mode 100644 tests_macos/drop_trace_test.phpt create mode 100644 tests_macos/mark_as_error.phpt create mode 100644 tests_macos/node_test.phpt create mode 100644 tests_macos/pinpoint_get_caller_arg.phpt create mode 100644 tests_macos/pinpoint_get_this.phpt create mode 100644 tests_macos/pinpoint_join_cut_curl_7.phpt create mode 100644 tests_macos/pinpoint_join_cut_curl_8.phpt create mode 100644 tests_macos/pinpoint_join_cut_extend_pdo.phpt create mode 100644 tests_macos/pinpoint_join_cut_mysqli.phpt create mode 100644 tests_macos/pinpoint_join_cut_pdo.phpt create mode 100644 tests_macos/pinpoint_join_cut_pdo_8.phpt create mode 100644 tests_macos/pinpoint_join_cut_redis.phpt create mode 100644 tests_macos/stack_fetal_error.phpt create mode 100644 tests_macos/trace_api_context_tcp.phpt create mode 100644 tests_macos/trace_api_test.phpt create mode 100644 tests_macos/trace_api_with_id.phpt create mode 100644 tests_macos/trace_limit_test-i448.phpt create mode 100644 tests_macos/trace_limit_test.phpt create mode 100644 tests_macos/unique_api_test.phpt diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dee6a886..c6b624dc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,108 +1,137 @@ name: CI -on: [pull_request, workflow_dispatch, push] +on: + pull_request: + workflow_dispatch: + push: + tags: + - "v*.*.*" env: MODULE_PAK: pinpoint_php-${{ github.head_ref || github.ref_name }} jobs: - # cpp: - # strategy: - # matrix: - # os: [ubuntu-latest, macos-13] - # runs-on: ${{ matrix.os }} - # steps: - # - uses: actions/checkout@v2 - # - name: actions-setup-cmake - # uses: jwlawson/actions-setup-cmake@v1.6 - # with: - # cmake-version: "3.16.x" - # - name: Build agent - # run: | - # cd common - # mkdir -p build - # cd build - # cmake -DWITH_TEST_CASE=1 -DWITH_CODECOVERAGE=1 -DCMAKE_BUILD_TYPE=Debug .. - # make - # ./bin/TestCommon - # - name: Codecovage - # uses: codecov/codecov-action@v4 - - # cpp-windows: - # runs-on: [windows-latest] - # steps: - # - uses: actions/checkout@v2 - - # - name: powershell allow... - # shell: cmd - # run: powershell -Command "Set-ExecutionPolicy RemoteSigned -Scope CurrentUser" - - # - name: Build agent - # run: | - # cd common - # cmake --no-warn-unused-cli -DWITH_TEST_CASE=1 -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -S. -B./build -G "Visual Studio 17 2022" -T host=x86 -A win32 - # cmake --build build --target ALL_BUILD --config debug -- - # ./build/bin/Debug/TestCommon.exe - - # memory-leak: - # needs: [cpp, cpp-windows] - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v2 - # - name: actions-setup-cmake - # uses: jwlawson/actions-setup-cmake@v1.6 - # with: - # cmake-version: "3.16.x" - # - name: Build agent - # run: | - # sudo apt update || echo "update failed,but try to overlook it" - # sudo apt install -y valgrind -y valgrind - # cd common - # mkdir -p build - # cd build - # cmake -DWITH_TEST_CASE=1 -DCMAKE_BUILD_TYPE=Debug .. - # make - # valgrind --leak-check=full \ - # --show-leak-kinds=all \ - # --track-origins=yes \ - # --verbose \ - # --log-file=valgrind-out.txt \ - # ./bin/TestCommon - # - name: Archive docs - # uses: actions/upload-artifact@v3 - # with: - # name: valgrind-out - # path: common/build/valgrind-out.txt - - # PHP: - # runs-on: ubuntu-latest - # needs: cpp - # strategy: - # matrix: - # php-version: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"] - # steps: - # - uses: actions/checkout@v2 - # with: - # submodules: "true" - # - name: update docker compose - # run: | - # wget "https://github.com/docker/compose/releases/latest/download/docker-compose-linux-x86_64" - # chmod +x docker-compose-linux-x86_64 - # ./docker-compose-linux-x86_64 version - # - name: start test environment - # run: | - # ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" build php-compatible --build-arg PHP_VERSION=${{ matrix.php-version }} - # ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" up php-compatible - # - name: Stop containers - # # if: always() - # run: ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" down php-compatible + cpp: + strategy: + matrix: + os: [ubuntu-latest, macos-13] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - name: actions-setup-cmake + uses: jwlawson/actions-setup-cmake@v1.6 + with: + cmake-version: "3.16.x" + - name: Build agent + run: | + cd common + mkdir -p build + cd build + cmake -DWITH_TEST_CASE=1 -DWITH_CODECOVERAGE=1 -DCMAKE_BUILD_TYPE=Debug .. + make + ./bin/TestCommon + - name: Codecovage + uses: codecov/codecov-action@v4 + + cpp-windows: + runs-on: [windows-latest] + steps: + - uses: actions/checkout@v2 + + - name: powershell allow... + shell: cmd + run: powershell -Command "Set-ExecutionPolicy RemoteSigned -Scope CurrentUser" + + - name: Build agent + run: | + cd common + cmake --no-warn-unused-cli -DWITH_TEST_CASE=1 -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -S. -B./build -G "Visual Studio 17 2022" -T host=x86 -A win32 + cmake --build build --target ALL_BUILD --config debug -- + ./build/bin/Debug/TestCommon.exe + + memory-leak: + needs: [cpp, cpp-windows] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: actions-setup-cmake + uses: jwlawson/actions-setup-cmake@v1.6 + with: + cmake-version: "3.16.x" + - name: Build agent + run: | + sudo apt update || echo "update failed,but try to overlook it" + sudo apt install -y valgrind -y valgrind + cd common + mkdir -p build + cd build + cmake -DWITH_TEST_CASE=1 -DCMAKE_BUILD_TYPE=Debug .. + make + valgrind --leak-check=full \ + --show-leak-kinds=all \ + --track-origins=yes \ + --verbose \ + --log-file=valgrind-out.txt \ + ./bin/TestCommon + - name: Archive docs + uses: actions/upload-artifact@v3 + with: + name: valgrind-out + path: common/build/valgrind-out.txt + + PHP: + runs-on: ubuntu-latest + needs: cpp + strategy: + matrix: + php-version: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"] + steps: + - uses: actions/checkout@v2 + with: + submodules: "true" + - name: update docker compose + run: | + wget "https://github.com/docker/compose/releases/latest/download/docker-compose-linux-x86_64" + chmod +x docker-compose-linux-x86_64 + ./docker-compose-linux-x86_64 version + - name: start test environment + run: | + ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" build php-compatible --build-arg PHP_VERSION=${{ matrix.php-version }} + ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" up php-compatible + - name: Stop containers + # if: always() + run: ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" down php-compatible + + PHP-MacOS: + runs-on: macos-latest + needs: cpp + strategy: + matrix: + php-version: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"] + ts: ["ts","nts"] + env: + SKIP_MACOS_ACTION: true + steps: + - uses: actions/checkout@v2 + with: + submodules: "true" + - name: Setup PHP with PECL extension + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + env: + phpts: ${{ matrix.ts }} + - name: build pinpoint_php + run: phpize && ./configure && make + - name: make test + run: make test TESTS="--show-diff tests_macos" PHP-Win-2019: runs-on: windows-2019 + needs: cpp-windows strategy: matrix: php-versions: [ "7.4", "7.3", "7.2","7.1","8.0", "8.1", "8.2", "8.3"] - # php-versions: [ "7.4"] arch: [ "x86" ,"x64"] ts: [ "ts", "nts" ] env: @@ -134,7 +163,8 @@ jobs: run: | # from https://github.com/php/setup-php-sdk/issues/7 nmake test TESTS="--show-diff tests_win32" - + echo "pinpoint_php_win32_pack_name=${{ env.MODULE_PAK }}-${{ matrix.php-versions }}-${{ matrix.ts }}-${{steps.setup-php-sdk.outputs.vs}}-${{ matrix.arch }}" | Out-File -FilePath $env:GITHUB_ENV -Append + - name: package run: | Move-Item -Path output/Release/php_pinpoint_php.* -Destination . -ErrorAction SilentlyContinue @@ -142,7 +172,7 @@ jobs: - uses: actions/upload-artifact@v4 with: - name: ${{ env.MODULE_PAK }}-${{ matrix.php-versions }}-${{ matrix.ts }}-${{steps.setup-php-sdk.outputs.vs}}-${{ matrix.arch }} + name: ${{ env.pinpoint_php_win32_pack_name }} path: | php_pinpoint_php.dll php_pinpoint_php.lib @@ -155,83 +185,108 @@ jobs: overwrite: true if-no-files-found: error - # pack_php_module: - # runs-on: ubuntu-latest - # needs: PHP - # steps: - # - uses: actions/checkout@v2 - # - name: Package pinpoint_php - # id: pack - # run: | - # tar -czf ${{ env.MODULE_PAK }} common/ config.m4 tests LICENSE pinpoint_php.cpp php_pinpoint_php.h - # md5=($(md5sum ${{ env.MODULE_PAK }} )) - # PACK_NAME=${{ env.MODULE_PAK }}-${md5}-$(date '+%Y-%m-%d').tar.gz - # mv ${{ env.MODULE_PAK }} $PACK_NAME - # echo "PACK=$PACK_NAME" >> $GITHUB_OUTPUT - - # - uses: actions/upload-artifact@v3 - # with: - # name: ${{ env.MODULE_PAK }} - # path: ${{ steps.pack.outputs.PACK }} - - # Python: - # strategy: - # matrix: - # os: [ubuntu-latest, macos-13] - # python-version: ["3.8", "3.9", "3.10", "3.11"] - # runs-on: ${{ matrix.os }} - # needs: [cpp, cpp-windows] - # steps: - # - uses: actions/checkout@v2 - # - uses: actions/setup-python@v2 - # with: - # python-version: ${{ matrix.python-version }} - # - name: run unittest - # run: | - # # ref https://github.com/pypa/setuptools/issues/3198 - # pip install -e . - # python -m unittest discover -s src/PY/test - # python-plugins: - # # timeout-minutes: 20 - # needs: Python - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v2 - # with: - # submodules: "true" - # - name: update docker compose - # run: | - # wget "https://github.com/docker/compose/releases/latest/download/docker-compose-linux-x86_64" - # chmod +x docker-compose-linux-x86_64 - # ./docker-compose-linux-x86_64 version - # # run: docker-compose -f "testapps/compose.yaml" build python-plugins - # # - name: build python-plugins - # - name: start test environment - # run: ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" up python-plugins --exit-code-from python-plugins - # - name: Stop containers - # # if: always() - # run: ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" down python-plugins - # Collector-agent: - # strategy: - # matrix: - # go-version: [1.18.x] - # os: [ubuntu-latest] - # runs-on: ${{ matrix.os }} - # steps: - # - name: Install Go - # uses: actions/setup-go@v2 - # with: - # go-version: ${{ matrix.go-version }} - # - name: Checkout code - # uses: actions/checkout@v2 - # with: - # submodules: "true" - - # - name: Setup protoc - # uses: arduino/setup-protoc@v2.1.0 - - # - run: | - # go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 - # go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2 - # export PATH="$PATH:$(go env GOPATH)/bin" - # cd collector-agent && make && go test ./... -v + - name: Download All Artifacts + uses: actions/download-artifact@v4 + if: startsWith(github.ref, 'refs/tags/') + with: + name: ${{ env.pinpoint_php_win32_pack_name }} + path: pinpoint-artifact + + - name: Release php_package + id: rel_php_pak + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + files: pinpoint-artifact/* + + pack_php_module: + runs-on: ubuntu-latest + needs: PHP + steps: + - uses: actions/checkout@v2 + - name: Setup PHP without composer + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + + - name: pecl package + run: pecl package + + # - name: Package pinpoint_php + # id: pack + # run: | + # tar -czf ${{ env.MODULE_PAK }} common/ config.m4 tests LICENSE pinpoint_php.cpp php_pinpoint_php.h + # md5=($(md5sum ${{ env.MODULE_PAK }} )) + # pinpoint_php_win32_pack_name=${{ env.MODULE_PAK }}-${md5}-$(date '+%Y-%m-%d').tar.gz + # mv ${{ env.MODULE_PAK }} $pinpoint_php_win32_pack_name + # echo "PACK=$pinpoint_php_win32_pack_name" >> $GITHUB_OUTPUT + + - uses: actions/upload-artifact@v3 + with: + name: ${{ env.MODULE_PAK }} + path: pinpoint_php*.tgz + + Python: + strategy: + matrix: + os: [ubuntu-latest, macos-13] + python-version: ["3.8", "3.9", "3.10", "3.11"] + runs-on: ${{ matrix.os }} + needs: [cpp, cpp-windows] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: run unittest + run: | + # ref https://github.com/pypa/setuptools/issues/3198 + pip install -e . + python -m unittest discover -s src/PY/test + + python-plugins: + needs: Python + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + submodules: "true" + - name: update docker compose + run: | + wget "https://github.com/docker/compose/releases/latest/download/docker-compose-linux-x86_64" + chmod +x docker-compose-linux-x86_64 + ./docker-compose-linux-x86_64 version + # run: docker-compose -f "testapps/compose.yaml" build python-plugins + # - name: build python-plugins + - name: start test environment + run: ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" up python-plugins --exit-code-from python-plugins + - name: Stop containers + # if: always() + run: ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" down python-plugins + + Collector-agent: + strategy: + matrix: + go-version: [1.18.x] + os: [ubuntu-latest,windows-latest,macos-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: "true" + + - name: Setup protoc + uses: arduino/setup-protoc@v2.1.0 + + - name: run unittest + run: | + go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 + go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2 + # export PATH="$PATH:$(go env GOPATH)/bin" + cd collector-agent && go mod tidy && go test ./... -v \ No newline at end of file diff --git a/common/CHANGES.md b/common/CHANGES.md index 17f07cbf..c89ce6e4 100644 --- a/common/CHANGES.md +++ b/common/CHANGES.md @@ -1,3 +1,6 @@ +## v0.5.3 2024-07-30 +- support unittest in macos + ## v0.5.2 2024-07-26 - fix `tick++` diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index cfe0b515..ce5c5088 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.13) -project(pinpoint VERSION 0.5.2 DESCRIPTION "pinpoint common library") +project(pinpoint VERSION 0.5.3 DESCRIPTION "pinpoint common library") set(CMAKE_CXX_STANDARD 11) diff --git a/common/include/common.h b/common/include/common.h index 463ea65a..15b726bc 100644 --- a/common/include/common.h +++ b/common/include/common.h @@ -73,7 +73,7 @@ static const NodeID E_ROOT_NODE = 0; static const E_NODE_LOC E_LOC_CURRENT = 0x0; static const E_NODE_LOC E_LOC_ROOT = 0x1; -#define PINPOINT_C_AGENT_API_VERSION "0.5.2" +#define PINPOINT_C_AGENT_API_VERSION "0.5.3" /** * @brief change logs diff --git a/common/src/common.cpp b/common/src/common.cpp index 6782dd4f..a2fddd03 100644 --- a/common/src/common.cpp +++ b/common/src/common.cpp @@ -78,6 +78,8 @@ class Agent { } if (span_timeout > 0) { trans->SyncSendAll(span_timeout); + } else if (span_timeout < 0) { + pp_trace("[unittest] current span was dropped"); } else { trans->PoolEventOnce(0); } diff --git a/config.m4 b/config.m4 index d102c977..ef46369c 100644 --- a/config.m4 +++ b/config.m4 @@ -11,13 +11,7 @@ if test "$PHP_PINPOINT_PHP" != "no"; then PHP_REQUIRE_CXX() PHP_SUBST(PINPOINT_PHP_SHARED_LIBADD) - PHP_ADD_LIBRARY(stdc++, 1, PINPOINT_PHP_SHARED_LIBADD) - PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/common/include) - PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/common/jsoncpp/include) - PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/common/jsoncpp/include) - PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/common/src) - AC_DEFINE(HAVE_PINPOINT_PHP, 1, [Whether you have pinpoint]) - + # echo "------Build common libraries------------" # mkdir -p PHP_EXT_SRCDIR()/build # cd build @@ -43,9 +37,20 @@ if test "$PHP_PINPOINT_PHP" != "no"; then common/jsoncpp/lib_json/json_value.cpp \ common/jsoncpp/lib_json/json_reader.cpp \ " - - - PINPOINT_PHP_SHARED_LIBADD="$PINPOINT_PHP_SHARED_LIBADD -lrt" + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + PINPOINT_PHP_SHARED_LIBADD="$PINPOINT_PHP_SHARED_LIBADD -lrt" + fi PHP_NEW_EXTENSION(pinpoint_php,$PINPOINT_SRCS, $ext_shared) -fi \ No newline at end of file + PHP_ADD_LIBRARY(stdc++, 1, PINPOINT_PHP_SHARED_LIBADD) + PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/common/include) + PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/common/jsoncpp/include) + PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/common/jsoncpp/include) + PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/common/src) + AC_DEFINE(HAVE_PINPOINT_PHP, 1, [Whether you have pinpoint]) + PHP_ADD_BUILD_DIR(common/src/) + PHP_ADD_BUILD_DIR(common/src/NodePool/) + PHP_ADD_BUILD_DIR(common/src/ConnectionPool/) + PHP_ADD_BUILD_DIR(common/src/Cache/) + PHP_ADD_BUILD_DIR(common/jsoncpp/lib_json/) +fi diff --git a/package.xml b/package.xml index 23193087..54d66e65 100644 --- a/package.xml +++ b/package.xml @@ -9,12 +9,18 @@ http://pear.php.net/dtd/package-2.0.xsd"> This extension provides an API pinpoint-apm and built-in function auto-injection - - Jason Mile - eeliu - liu_ming_yi@outlook.com - yes - + + Jason Mile + eeliu + liu_ming_yi@outlook.com + yes + + + dl_cd_pinpoint + dl_cd_pinpoint + dl_cd_pinpoint@navercorp.com + yes + 2024-07-29 0.5.2 diff --git a/tests_macos/add_root_trace.phpt b/tests_macos/add_root_trace.phpt new file mode 100644 index 00000000..5aad9b2c --- /dev/null +++ b/tests_macos/add_root_trace.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test pinpoint_unique_id +--SKIPIF-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=-1 +pinpoint_php.UnitTest=true +pinpoint_php.DebugReport=true +--FILE-- + +--INI-- +pinpoint_php.DebugReport=false +--FILE-- +foo('hello pinpoint',1,array('1'=>2,'c'=>3,'e'=>5)); +Foo::static_foo('hello pinpoint',1,array('1'=>2,'c'=>3,'e'=>5)); +$foo->test_none(); +var_dump($foo->return_all("23",1,null)); + +echo "test anonymous \n"; +$name = 'eeliu'; +$nobody = function ($arg) use (&$name) { + var_dump(\pinpoint_get_func_ref_args()); + $name = 'eeliu-01'; + $arg = $arg.$name; + return \pinpoint_get_func_ref_args(); +}; +var_dump($nobody("hello ")); +echo "\n"; + +echo "test pinpoint_get_func_ref_args call in call_user_func_array \n"; + +function foo_ref($a,&$b,&$c) +{ + var_dump(func_get_args()); + $b = 10; + $c = 11; + return array($b,$c); +} + +function aop_foo_ref($a,&$b,&$c) +{ + $args = \pinpoint_get_func_ref_args(); + return call_user_func_array('foo_ref',$args); +} +$b =2; +$c = 12; +var_dump(aop_foo_ref("adf",$b,$c)); +echo "b = $b \n"; +echo "c = $c \n"; + +--EXPECTF-- +array(4) { + [0]=> + &int(100) + [1]=> + int(1) + [2]=> + int(3) + [3]=> + int(4) +} +string(12) "hello php!!!" + +Warning: pinpoint_get_func_ref_args(): Called from the global scope - no function context in %s on line 18 +bool(false) +call __construct +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +array(3) { + [0]=> + string(14) "hello pinpoint" + [1]=> + int(1) + [2]=> + array(3) { + [1]=> + int(2) + ["c"]=> + int(3) + ["e"]=> + int(5) + } +} +array(3) { + [0]=> + string(14) "hello pinpoint" + [1]=> + int(1) + [2]=> + array(3) { + [1]=> + int(2) + ["c"]=> + int(3) + ["e"]=> + int(5) + } +} +array(0) { +} +array(3) { + [0]=> + string(2) "23" + [1]=> + int(1) + [2]=> + NULL +} +test anonymous +array(1) { + [0]=> + string(6) "hello " +} +array(1) { + [0]=> + string(14) "hello eeliu-01" +} + +test pinpoint_get_func_ref_args call in call_user_func_array +array(3) { + [0]=> + string(3) "adf" + [1]=> + int(2) + [2]=> + int(12) +} +array(2) { + [0]=> + int(10) + [1]=> + int(11) +} +b = 10 +c = 11 +call __destruct +array(0) { +} \ No newline at end of file diff --git a/tests_macos/app_info_test.phpt b/tests_macos/app_info_test.phpt new file mode 100644 index 00000000..7c7e1817 --- /dev/null +++ b/tests_macos/app_info_test.phpt @@ -0,0 +1,16 @@ +--TEST-- +app info +--SKIPIF-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=0 +pinpoint_php.UnitTest=true +pinpoint_php.DebugReport=true +--FILE-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=0 +pinpoint_php.UnitTest=true +pinpoint_php.DebugReport=true +--FILE-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=-1 +pinpoint_php.UnitTest=true +;pinpoint_php._limit for internal use. User do not use it +pinpoint_php._limit=yes +pinpoint_php.DebugReport=true +--FILE-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=0 +pinpoint_php.UnitTest=true +pinpoint_php.DebugReport=true +--FILE-- + +--INI-- +pinpoint_php.DebugReport=true +--FILE-- +abc); + var_dump($f->abc_s); + echo " update foo members \n"; + $f->abc = 1234; + $f->abc_s= "hello pinpoint"; + } + }; + + $onBefore(); + } + public $abc = 123; + public $abc_s = "123"; +} + +$f = new Foo(); +$f->output(); +var_dump($f->abc); +var_dump($f->abc_s); +var_dump(pinpoint_get_this()); + +echo "test static method \n"; +class S_Foo +{ + public static $my_static = 'foo'; + + public static function staticValue() { + $f = pinpoint_get_this(); + var_dump($f); + return self::$my_static; + } +} + +$sf = new S_Foo(); +S_Foo::staticValue(); + +--EXPECTF-- +int(123) +string(3) "123" + update foo members +int(1234) +string(14) "hello pinpoint" +[pinpoint] [%d] [%d]pinpoint_get_this: not support, no this +bool(false) +test static method +[pinpoint] [%d] [%d]pinpoint_get_this: not support, no this +bool(false) \ No newline at end of file diff --git a/tests_macos/pinpoint_join_cut_curl_7.phpt b/tests_macos/pinpoint_join_cut_curl_7.phpt new file mode 100644 index 00000000..72ef024d --- /dev/null +++ b/tests_macos/pinpoint_join_cut_curl_7.phpt @@ -0,0 +1,233 @@ +--TEST-- +pinpoint_php pinpoint_join_cut_cut +--SKIPIF-- +=')) +{ print "skip"; + print "only works in php7"; +} +if(getenv('SKIP_WINDOWS_ACTION', true)){ + print "skip"; +} +?> +--INI-- +pinpoint_php.DebugReport=true + +--EXTENSIONS-- +json +curl + +--FILE-- + +--INI-- +pinpoint_php.DebugReport=true + +--EXTENSIONS-- +json + +--FILE-- +=')){ + print "skip"; + print phpversion() . ">= 8.2.0"; +} + +if(getenv('SKIP_WINDOWS_ACTION', true)){ + print "skip"; +} + +?> +--INI-- +pinpoint_php.DebugReport=true +--EXTENSIONS-- +pdo_mysql +--FILE-- +dsn = $dsn; + echo "attached dsn \n"; + } + }, + function ($ret) { + echo "on_end \n"; + }, + function ($e) { + echo "on_exception \n"; + } +); + +$pdo_exec = "PDO::exec"; +_pinpoint_join_cut( + ["PDO", "exec"], + function ($statement) use ($pdo_exec) { + echo "$pdo_exec: on_before: $statement \n"; + }, + function ($ret) use ($pdo_exec) { + echo "$pdo_exec : on_end \n"; + }, + function ($e) use ($pdo_exec) { + echo "on_exception \n"; + } +); + +class MyPDO extends PDO +{ + +} +$dbname = "employees"; +$pdo = new MyPDO("mysql:host=dev-mysql;dbname=$dbname", 'root', 'password'); +$pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); +$pdo->abc = "123"; +$sql = "CREATE table IF NOT EXISTS pdo_test( + ID INT( 11 ) AUTO_INCREMENT PRIMARY KEY, + Name VARCHAR( 250 ) NOT NULL, + AGE tinyint(1) unsigned NOT NULL default '1' );"; +$ret = $pdo->exec($sql); +if ($ret === false) { + echo "create pdo_test failed" . $pdo->errorCode(); +} + +$sql = "INSERT INTO pdo_test (NAME, AGE) +VALUES ('a',1),('b',1),('c',3),('d',1);"; +$ret = $pdo->exec($sql); +var_dump($ret); + +$unbufferedResult = $pdo->query("SELECT * FROM pdo_test"); +foreach ($unbufferedResult as $row) { + var_dump($unbufferedResult); +} + +$sth = $pdo->prepare('SELECT name FROM pdo_test + WHERE AGE = :AGE limit 3'); +/* Names can be prefixed with colons ":" too (optional) */ +$sth->bindValue(':AGE', 1); +$ret = $sth->execute(); +var_dump($ret); +$ret = $sth->fetch(); +var_dump($ret); +$ret = $sth->fetchAll(); +var_dump($ret); +var_dump($pdo->abc); +var_dump($pdo->dsn); +$sql = 'DROP TABLE pdo_test'; +$ret = $pdo->exec($sql); + + +--EXPECTF-- +[pinpoint] [%d] [%d]try to interceptor module(class)/function=pdo:__construct +[pinpoint] [%d] [%d]added interceptor on `module`: pdo::__construct success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=pdo:exec +[pinpoint] [%d] [%d]added interceptor on `module`: pdo::exec success +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:pdo::__construct +on_before: mysql:host=dev-mysql;dbname=employees +attached dsn +[pinpoint] [%d] [%d] call_interceptor_before:pdo::__construct return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +on_end +[pinpoint] [%d] [%d]call_interceptor_end: pdo::__construct +int(4) +object(PDOStatement)#8 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +object(PDOStatement)#8 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +object(PDOStatement)#8 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +object(PDOStatement)#8 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +bool(true) +array(2) { + ["name"]=> + string(1) "a" + [0]=> + string(1) "a" +} +array(2) { + [0]=> + array(2) { + ["name"]=> + string(1) "b" + [0]=> + string(1) "b" + } + [1]=> + array(2) { + ["name"]=> + string(1) "d" + [0]=> + string(1) "d" + } +} +string(3) "123" +string(37) "mysql:host=dev-mysql;dbname=employees" +[pinpoint] [%d] [%d]start free interceptor: pdo::__construct +[pinpoint] [%d] [%d]start free interceptor: pdo::exec \ No newline at end of file diff --git a/tests_macos/pinpoint_join_cut_mysqli.phpt b/tests_macos/pinpoint_join_cut_mysqli.phpt new file mode 100644 index 00000000..08af04fb --- /dev/null +++ b/tests_macos/pinpoint_join_cut_mysqli.phpt @@ -0,0 +1,90 @@ +--TEST-- +pinpoint_php pinpoint_join_cut_mysqli +--SKIPIF-- + +--INI-- +pinpoint_php.DebugReport=true +--EXTENSIONS-- +mysqli +--FILE-- + +host_info; + } + echo "$db_host \n"; +}; + +$on_before_func = function (...$args) { + $mysqli = $args[0]; + $db_host = "localhost"; + if ($mysqli instanceof mysqli) { + $db_host = $mysqli->host_info; + } + echo "$db_host \n"; +}; + +$on_end = function ($ret) { + +}; + +$on_exception = function ($exp) { +}; + + +_pinpoint_join_cut(['mysqli_query'], $on_before_func, $on_end, $on_exception); +_pinpoint_join_cut(['mysqli', 'query'], $on_before, $on_end, $on_exception); + + + +mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); +$mysqli = new mysqli(); + +$mysqli->connect('dev-mysql', "root", "password", "employees", 3306); + +$result = $mysqli->query("SELECT * FROM `dept_emp_latest_date` LIMIT 1000;"); +printf("Select returned %d rows.\n", $result->num_rows); + +$stmt = $mysqli->prepare("SELECT * FROM employees WHERE emp_no=?"); +$id = 10005; +$stmt->bind_param("i", $id); +$stmt->execute(); +$stmt->fetch(); +$stmt->free_result(); +mysqli_query($mysqli, "SELECT * FROM `dept_emp_latest_date` LIMIT 1000;"); + +$s_stmt = mysqli_prepare($mysqli, "SELECT * FROM employees WHERE emp_no=?"); +mysqli_stmt_bind_param($s_stmt, "i", $id); +mysqli_stmt_execute($stmt); + + + + +--EXPECTF-- +[pinpoint] [%d] [%d]try to interceptor function=mysqli_query +[pinpoint] [%d] [%d]added interceptor on `function`: mysqli_query success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=mysqli:query +[pinpoint] [%d] [%d]added interceptor on `module`: mysqli::query success +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:mysqli::query +dev-mysql via TCP/IP +[pinpoint] [%d] [%d] call_interceptor_before:mysqli::query return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +[pinpoint] [%d] [%d]call_interceptor_end: mysqli::query +Select returned 1000 rows. +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:mysqli_query +dev-mysql via TCP/IP +[pinpoint] [%d] [%d] call_interceptor_before:mysqli_query return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +[pinpoint] [%d] [%d]call_interceptor_end: mysqli_query +[pinpoint] [%d] [%d]start free interceptor: mysqli_query +[pinpoint] [%d] [%d]start free interceptor: mysqli::query \ No newline at end of file diff --git a/tests_macos/pinpoint_join_cut_pdo.phpt b/tests_macos/pinpoint_join_cut_pdo.phpt new file mode 100644 index 00000000..35df243e --- /dev/null +++ b/tests_macos/pinpoint_join_cut_pdo.phpt @@ -0,0 +1,176 @@ +--TEST-- +pinpoint_php pinpoint_join_cut_pdo +--SKIPIF-- +=')){ + print "skip"; + print phpversion() . ">= 8.2.0"; +} +if(getenv('SKIP_MACOS_ACTION', true)){ + print "skip"; +} + +?> +--INI-- +pinpoint_php.DebugReport=true +--EXTENSIONS-- +pdo_mysql +--FILE-- +dsn = $dsn; + echo "attached dsn \n"; + } + }, + function ($ret) { + echo "on_end \n"; + }, + function ($e) { + echo "on_exception \n"; + } +); +$pdo_exec = "PDO::exec"; +_pinpoint_join_cut( + ["PDO", "exec"], + function ($statement) use ($pdo_exec) { + echo "$pdo_exec: on_before: $statement \n"; + }, + function ($ret) use ($pdo_exec) { + echo "$pdo_exec : on_end \n"; + }, + function ($e) use ($pdo_exec) { + echo "on_exception \n"; + } +); + + +echo "case: pdo() \n"; + +$dbname = "employees"; +$pdo = new PDO("mysql:host=dev-mysql;dbname=$dbname", 'root', 'password'); +$pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); +$pdo->abc = "123"; +$sql = "CREATE table IF NOT EXISTS pdo_test( + ID INT( 11 ) AUTO_INCREMENT PRIMARY KEY, + Name VARCHAR( 250 ) NOT NULL, + AGE tinyint(1) unsigned NOT NULL default '1' );"; +$ret = $pdo->exec($sql); +if ($ret === false) { + echo "create pdo_test failed" . $pdo->errorCode(); +} + +$sql = "INSERT INTO pdo_test (NAME, AGE) +VALUES ('a',1),('b',1),('c',3),('d',1);"; +$ret = $pdo->exec($sql); +var_dump($ret); + +$unbufferedResult = $pdo->query("SELECT * FROM pdo_test"); +foreach ($unbufferedResult as $row) { + var_dump($unbufferedResult); +} + +$sth = $pdo->prepare('SELECT name FROM pdo_test + WHERE AGE = :AGE limit 3'); +/* Names can be prefixed with colons ":" too (optional) */ +$sth->bindValue(':AGE', 1); +$ret = $sth->execute(); +var_dump($ret); +$ret = $sth->fetch(); +var_dump($ret); +$ret = $sth->fetchAll(); +var_dump($ret); +var_dump($pdo->abc); +var_dump($pdo->dsn); +$sql = 'DROP TABLE pdo_test'; +$ret = $pdo->exec($sql); + + +--EXPECTF-- +[pinpoint] [%d] [%d]try to interceptor module(class)/function=pdo:__construct +[pinpoint] [%d] [%d]added interceptor on `module`: pdo::__construct success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=pdo:exec +[pinpoint] [%d] [%d]added interceptor on `module`: pdo::exec success +case: pdo() +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:pdo::__construct +on_before: mysql:host=dev-mysql;dbname=employees +attached dsn +[pinpoint] [%d] [%d] call_interceptor_before:pdo::__construct return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +on_end +[pinpoint] [%d] [%d]call_interceptor_end: pdo::__construct +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:pdo::exec +PDO::exec: on_before: CREATE table IF NOT EXISTS pdo_test( + ID INT( 11 ) AUTO_INCREMENT PRIMARY KEY, + Name VARCHAR( 250 ) NOT NULL, + AGE tinyint(1) unsigned NOT NULL default '1' ); +[pinpoint] [%d] [%d] call_interceptor_before:pdo::exec return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +PDO::exec : on_end +[pinpoint] [%d] [%d]call_interceptor_end: pdo::exec +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:pdo::exec +PDO::exec: on_before: INSERT INTO pdo_test (NAME, AGE) +VALUES ('a',1),('b',1),('c',3),('d',1); +[pinpoint] [%d] [%d] call_interceptor_before:pdo::exec return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +PDO::exec : on_end +[pinpoint] [%d] [%d]call_interceptor_end: pdo::exec +int(4) +object(PDOStatement)#8 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +object(PDOStatement)#8 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +object(PDOStatement)#8 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +object(PDOStatement)#8 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +bool(true) +array(2) { + ["name"]=> + string(1) "a" + [0]=> + string(1) "a" +} +array(2) { + [0]=> + array(2) { + ["name"]=> + string(1) "b" + [0]=> + string(1) "b" + } + [1]=> + array(2) { + ["name"]=> + string(1) "d" + [0]=> + string(1) "d" + } +} +string(3) "123" +string(37) "mysql:host=dev-mysql;dbname=employees" +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:pdo::exec +PDO::exec: on_before: DROP TABLE pdo_test +[pinpoint] [%d] [%d] call_interceptor_before:pdo::exec return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +PDO::exec : on_end +[pinpoint] [%d] [%d]call_interceptor_end: pdo::exec +[pinpoint] [%d] [%d]start free interceptor: pdo::__construct +[pinpoint] [%d] [%d]start free interceptor: pdo::exec \ No newline at end of file diff --git a/tests_macos/pinpoint_join_cut_pdo_8.phpt b/tests_macos/pinpoint_join_cut_pdo_8.phpt new file mode 100644 index 00000000..73b3c2f1 --- /dev/null +++ b/tests_macos/pinpoint_join_cut_pdo_8.phpt @@ -0,0 +1,187 @@ +--TEST-- +pinpoint_php pinpoint_join_cut_pdo_8 +--SKIPIF-- + +--INI-- +pinpoint_php.DebugReport=true +--EXTENSIONS-- +pdo_mysql + +--FILE-- +setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); +$sql = "CREATE table IF NOT EXISTS pdo_test( + ID INT( 11 ) AUTO_INCREMENT PRIMARY KEY, + Name VARCHAR( 250 ) NOT NULL, + AGE tinyint(1) unsigned NOT NULL default '1' );"; +$ret = $pdo->exec($sql); +if ($ret === false) { + echo "create pdo_test failed" . $pdo->errorCode(); +} + +$sql = "INSERT INTO pdo_test (NAME, AGE) +VALUES ('a',1),('b',1),('c',3),('d',1);"; +$ret = $pdo->exec($sql); +var_dump($ret); + +$unbufferedResult = $pdo->query("SELECT * FROM pdo_test"); +foreach ($unbufferedResult as $row) { + var_dump($unbufferedResult); +} + +$sth = $pdo->prepare('SELECT name FROM pdo_test + WHERE AGE = :AGE limit 3'); +/* Names can be prefixed with colons ":" too (optional) */ +$sth->bindValue(':AGE', 1); +$ret = $sth->execute(); +var_dump($ret); +$ret = $sth->fetch(); +var_dump($ret); +$ret = $sth->fetchAll(); +var_dump($ret); +var_dump($weakMap[$pdo]); +$sql = 'DROP TABLE pdo_test'; +$ret = $pdo->exec($sql); + + + +--EXPECTF-- +[pinpoint] [%d] [%d]try to interceptor module(class)/function=pdo:__construct +[pinpoint] [%d] [%d]added interceptor on `module`: pdo::__construct success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=pdo:exec +[pinpoint] [%d] [%d]added interceptor on `module`: pdo::exec success +case: pdo() +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:pdo::__construct +on_before: mysql:host=dev-mysql;dbname=employees +attached dsn +[pinpoint] [%d] [%d] call_interceptor_before:pdo::__construct return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +on_end +[pinpoint] [%d] [%d]call_interceptor_end: pdo::__construct +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:pdo::exec +PDO::exec: on_before: CREATE table IF NOT EXISTS pdo_test( + ID INT( 11 ) AUTO_INCREMENT PRIMARY KEY, + Name VARCHAR( 250 ) NOT NULL, + AGE tinyint(1) unsigned NOT NULL default '1' ); +mysql:host=dev-mysql;dbname=employees +[pinpoint] [%d] [%d] call_interceptor_before:pdo::exec return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +PDO::exec : on_end +[pinpoint] [%d] [%d]call_interceptor_end: pdo::exec +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:pdo::exec +PDO::exec: on_before: INSERT INTO pdo_test (NAME, AGE) +VALUES ('a',1),('b',1),('c',3),('d',1); +mysql:host=dev-mysql;dbname=employees +[pinpoint] [%d] [%d] call_interceptor_before:pdo::exec return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +PDO::exec : on_end +[pinpoint] [%d] [%d]call_interceptor_end: pdo::exec +int(4) +object(PDOStatement)#9 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +object(PDOStatement)#9 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +object(PDOStatement)#9 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +object(PDOStatement)#9 (1) { + ["queryString"]=> + string(22) "SELECT * FROM pdo_test" +} +bool(true) +array(2) { + ["name"]=> + string(1) "a" + [0]=> + string(1) "a" +} +array(2) { + [0]=> + array(2) { + ["name"]=> + string(1) "b" + [0]=> + string(1) "b" + } + [1]=> + array(2) { + ["name"]=> + string(1) "d" + [0]=> + string(1) "d" + } +} +string(37) "mysql:host=dev-mysql;dbname=employees" +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:pdo::exec +PDO::exec: on_before: DROP TABLE pdo_test +mysql:host=dev-mysql;dbname=employees +[pinpoint] [%d] [%d] call_interceptor_before:pdo::exec return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +PDO::exec : on_end +[pinpoint] [%d] [%d]call_interceptor_end: pdo::exec +[pinpoint] [%d] [%d]start free interceptor: pdo::__construct +[pinpoint] [%d] [%d]start free interceptor: pdo::exec \ No newline at end of file diff --git a/tests_macos/pinpoint_join_cut_redis.phpt b/tests_macos/pinpoint_join_cut_redis.phpt new file mode 100644 index 00000000..a6ab9803 --- /dev/null +++ b/tests_macos/pinpoint_join_cut_redis.phpt @@ -0,0 +1,295 @@ +--TEST-- +pinpoint_php pinpoint_join_cut_redis +--SKIPIF-- + +--INI-- +pinpoint_php.DebugReport=true +--EXTENSIONS-- +json +redis +--FILE-- + 'redis', + 'port' => 6379, + 'connectTimeout' => 2.5 +]); +assert($redis->info() !== false); + +echo "case: redis() \n"; +$redis = new Redis(); +$redis->connect('redis', 6379); +assert($redis->info() !== false); + +echo "case: redis() \n"; +$redis = new Redis(); +$redis->pconnect('redis', 6379); +assert($redis->info() !== false); + +echo "case: strings \n"; +$redis = new Redis(); +$redis->pconnect('redis', 6379); +$redis->get("a"); +$redis->set("a", "b"); +$redis->setNx("a", "10"); +$redis->append("ar", "aa"); +$redis->setRange("ar", 0, "bb"); +$redis->get("ar"); +$redis->getRange("ar", 0, 2); +$redis->strlen("ar"); +$redis->getBit("ar", 1); +$redis->setBit("ar", 1, 3); +var_dump($redis->get("ar")); +$redis->mSet(['foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz']); +var_dump($redis->exists('foo', 'bar', 'baz', 'not exists')); +$redis->flushdb(); +--EXPECTF-- +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:info +[pinpoint] [%d] [%d]added interceptor on `module`: redis::info success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:get +[pinpoint] [%d] [%d]added interceptor on `module`: redis::get success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:set +[pinpoint] [%d] [%d]added interceptor on `module`: redis::set success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:setnx +[pinpoint] [%d] [%d]added interceptor on `module`: redis::setnx success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:append +[pinpoint] [%d] [%d]added interceptor on `module`: redis::append success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:getrange +[pinpoint] [%d] [%d]added interceptor on `module`: redis::getrange success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:setrange +[pinpoint] [%d] [%d]added interceptor on `module`: redis::setrange success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:strlen +[pinpoint] [%d] [%d]added interceptor on `module`: redis::strlen success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:getbit +[pinpoint] [%d] [%d]added interceptor on `module`: redis::getbit success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:setbit +[pinpoint] [%d] [%d]added interceptor on `module`: redis::setbit success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:mset +[pinpoint] [%d] [%d]added interceptor on `module`: redis::mset success +[pinpoint] [%d] [%d]try to interceptor module(class)/function=redis:msetnx +[pinpoint] [%d] [%d]added interceptor on `module`: redis::msetnx success +case: redis(xxx) +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::info +Redis::info before: +[pinpoint] [%d] [%d] call_interceptor_before:redis::info return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::info end +[pinpoint] [%d] [%d]call_interceptor_end: redis::info +case: redis() +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::info +Redis::info before: +[pinpoint] [%d] [%d] call_interceptor_before:redis::info return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::info end +[pinpoint] [%d] [%d]call_interceptor_end: redis::info +case: redis() +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::info +Redis::info before: +[pinpoint] [%d] [%d] call_interceptor_before:redis::info return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::info end +[pinpoint] [%d] [%d]call_interceptor_end: redis::info +case: strings +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::get +Redis::get before: a +[pinpoint] [%d] [%d] call_interceptor_before:redis::get return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::get end +[pinpoint] [%d] [%d]call_interceptor_end: redis::get +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::set +Redis::set before: a : b +[pinpoint] [%d] [%d] call_interceptor_before:redis::set return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::set end +[pinpoint] [%d] [%d]call_interceptor_end: redis::set +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::setnx +Redis::setNx before: a : 10 +[pinpoint] [%d] [%d] call_interceptor_before:redis::setnx return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::setNx end +[pinpoint] [%d] [%d]call_interceptor_end: redis::setnx +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::append +Redis::append before: ar : aa +[pinpoint] [%d] [%d] call_interceptor_before:redis::append return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::append end +[pinpoint] [%d] [%d]call_interceptor_end: redis::append +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::setrange +Redis::setRange before: ar +[pinpoint] [%d] [%d] call_interceptor_before:redis::setrange return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::setRange end +[pinpoint] [%d] [%d]call_interceptor_end: redis::setrange +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::get +Redis::get before: ar +[pinpoint] [%d] [%d] call_interceptor_before:redis::get return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::get end +[pinpoint] [%d] [%d]call_interceptor_end: redis::get +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::getrange +Redis::getRange before: ar +[pinpoint] [%d] [%d] call_interceptor_before:redis::getrange return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::getRange end +[pinpoint] [%d] [%d]call_interceptor_end: redis::getrange +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::strlen +Redis::strlen before: ar +[pinpoint] [%d] [%d] call_interceptor_before:redis::strlen return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::strlen end +[pinpoint] [%d] [%d]call_interceptor_end: redis::strlen +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::getbit +Redis::getBit before: ar : 1 +[pinpoint] [%d] [%d] call_interceptor_before:redis::getbit return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::getBit end +[pinpoint] [%d] [%d]call_interceptor_end: redis::getbit +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::setbit +Redis::setBit before: ar +[pinpoint] [%d] [%d] call_interceptor_before:redis::setbit return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::setBit end +[pinpoint] [%d] [%d]call_interceptor_end: redis::setbit +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::get +Redis::get before: ar +[pinpoint] [%d] [%d] call_interceptor_before:redis::get return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::get end +[pinpoint] [%d] [%d]call_interceptor_end: redis::get +string(2) "bb" +[pinpoint] [%d] [%d]pinpoint_interceptor_handler_entry: handle func/method:redis::mset +Redis::mSet before: +[pinpoint] [%d] [%d] call_interceptor_before:redis::mset return type(1) zval +[pinpoint] [%d] [%d]replace_ex_caller_parameters return value must be `an array` +Redis::mSet end +[pinpoint] [%d] [%d]call_interceptor_end: redis::mset +int(3) +[pinpoint] [%d] [%d]start free interceptor: redis::info +[pinpoint] [%d] [%d]start free interceptor: redis::get +[pinpoint] [%d] [%d]start free interceptor: redis::set +[pinpoint] [%d] [%d]start free interceptor: redis::setnx +[pinpoint] [%d] [%d]start free interceptor: redis::append +[pinpoint] [%d] [%d]start free interceptor: redis::getrange +[pinpoint] [%d] [%d]start free interceptor: redis::setrange +[pinpoint] [%d] [%d]start free interceptor: redis::strlen +[pinpoint] [%d] [%d]start free interceptor: redis::getbit +[pinpoint] [%d] [%d]start free interceptor: redis::setbit +[pinpoint] [%d] [%d]start free interceptor: redis::mset +[pinpoint] [%d] [%d]start free interceptor: redis::msetnx \ No newline at end of file diff --git a/tests_macos/stack_fetal_error.phpt b/tests_macos/stack_fetal_error.phpt new file mode 100644 index 00000000..1a390eb8 --- /dev/null +++ b/tests_macos/stack_fetal_error.phpt @@ -0,0 +1,62 @@ +--TEST-- +pinpoint_php internal test case [pinpoint_test_main] +--SKIPIF-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=-1 +pinpoint_php.UnitTest=true +;pinpoint_php._limit for internal use. User do not use it +pinpoint_php._limit=yes +pinpoint_php.DebugReport=true +--FILE-- + +--INI-- +pinpoint_php.CollectorHost=tcp:127.0.0.1:9999 +pinpoint_php.SendSpanTimeOutMs=-1 +pinpoint_php.UnitTest=true +;pinpoint_php._limit for internal use. User do not use it +pinpoint_php._limit=yes +pinpoint_php.DebugReport=true +--FILE-- + +--EXPECTF-- +[pinpoint] [%d] [%d] [0] pinpoint_start child [128] +string(1) "a" +string(1) "b" +string(1) "c" +[pinpoint] [%d] [%d] pinpoint_get_context_key [128] failed with map::at: key not found, parameters:not exist +bool(false) +[pinpoint] [%d] [%d]this span:({":E":%d,":FT":1500,":S":%d}) +[pinpoint] [%d] [%d][unittest] current span was dropped +[pinpoint] [%d] [%d] [128] pinpoint_end_trace Done! +[pinpoint] [%d] [%d] [0] pinpoint_start child [128] +[pinpoint] [%d] [%d] [128] pinpoint_start child [127] +string(1) "c" +string(1) "b" +string(1) "a" +[pinpoint] [%d] [%d] pinpoint_get_context_key [127] failed with map::at: key not found, parameters:not exist +bool(false) +[pinpoint] [%d] [%d] [127] pinpoint_end_trace Done! +[pinpoint] [%d] [%d]this span:({":E":%d,":FT":1500,":S":%d,"calls":[{":E":%d,":S":%d}]}) +[pinpoint] [%d] [%d][unittest] current span was dropped +[pinpoint] [%d] [%d] [128] pinpoint_end_trace Done! +{ + "common_library_version" : "%s", + "pool_free_node" : 128, + "pool_total_node" : 128 +} \ No newline at end of file diff --git a/tests_macos/trace_api_test.phpt b/tests_macos/trace_api_test.phpt new file mode 100644 index 00000000..362d035a --- /dev/null +++ b/tests_macos/trace_api_test.phpt @@ -0,0 +1,134 @@ +--TEST-- +Check call statck +--SKIPIF-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=0 +pinpoint_php.UnitTest=true +;pinpoint_php._limit for internal use. User do not use it +pinpoint_php._limit=yes +pinpoint_php.DebugReport=true +--FILE-- +ouput("234",3432); + usleep(2000); +} + + +echo _pinpoint_start_trace()."\n"; + +_pinpoint_add_clue("name","ouput_234"); +for($x = 0;$x <10;$x++){ + ouput_234(1,3); +} +_pinpoint_add_clue("args",'a,$b'); +_pinpoint_add_clue("ret",'a,$b'); + +echo _pinpoint_end_trace()."\n"; + + +?> +--EXPECTF-- +[pinpoint] [%d] [%d] [0] pinpoint_start child [128] +128 +[pinpoint] [%d] [%d] [128] add clue key:name value:ouput_234 +[pinpoint] [%d] [%d] [128] pinpoint_start child [127] +127 +[pinpoint] [%d] [%d] [127] add clue key:name value:Foo +[pinpoint] [%d] [%d] [127] add clues:1:234,3432 +[pinpoint] [%d] [%d] [127] add clues:2:234 +[pinpoint] [%d] [%d] [127] pinpoint_end_trace Done! +128 +[pinpoint] [%d] [%d] [128] pinpoint_start child [126] +126 +[pinpoint] [%d] [%d] [126] add clue key:name value:Foo +[pinpoint] [%d] [%d] [126] add clues:1:234,3432 +[pinpoint] [%d] [%d] [126] add clues:2:234 +[pinpoint] [%d] [%d] [126] pinpoint_end_trace Done! +128 +[pinpoint] [%d] [%d] [128] pinpoint_start child [125] +125 +[pinpoint] [%d] [%d] [125] add clue key:name value:Foo +[pinpoint] [%d] [%d] [125] add clues:1:234,3432 +[pinpoint] [%d] [%d] [125] add clues:2:234 +[pinpoint] [%d] [%d] [125] pinpoint_end_trace Done! +128 +[pinpoint] [%d] [%d] [128] pinpoint_start child [124] +124 +[pinpoint] [%d] [%d] [124] add clue key:name value:Foo +[pinpoint] [%d] [%d] [124] add clues:1:234,3432 +[pinpoint] [%d] [%d] [124] add clues:2:234 +[pinpoint] [%d] [%d] [124] pinpoint_end_trace Done! +128 +[pinpoint] [%d] [%d] [128] pinpoint_start child [123] +123 +[pinpoint] [%d] [%d] [123] add clue key:name value:Foo +[pinpoint] [%d] [%d] [123] add clues:1:234,3432 +[pinpoint] [%d] [%d] [123] add clues:2:234 +[pinpoint] [%d] [%d] [123] pinpoint_end_trace Done! +128 +[pinpoint] [%d] [%d] [128] pinpoint_start child [122] +122 +[pinpoint] [%d] [%d] [122] add clue key:name value:Foo +[pinpoint] [%d] [%d] [122] add clues:1:234,3432 +[pinpoint] [%d] [%d] [122] add clues:2:234 +[pinpoint] [%d] [%d] [122] pinpoint_end_trace Done! +128 +[pinpoint] [%d] [%d] [128] pinpoint_start child [121] +121 +[pinpoint] [%d] [%d] [121] add clue key:name value:Foo +[pinpoint] [%d] [%d] [121] add clues:1:234,3432 +[pinpoint] [%d] [%d] [121] add clues:2:234 +[pinpoint] [%d] [%d] [121] pinpoint_end_trace Done! +128 +[pinpoint] [%d] [%d] [128] pinpoint_start child [120] +120 +[pinpoint] [%d] [%d] [120] add clue key:name value:Foo +[pinpoint] [%d] [%d] [120] add clues:1:234,3432 +[pinpoint] [%d] [%d] [120] add clues:2:234 +[pinpoint] [%d] [%d] [120] pinpoint_end_trace Done! +128 +[pinpoint] [%d] [%d] [128] pinpoint_start child [119] +119 +[pinpoint] [%d] [%d] [119] add clue key:name value:Foo +[pinpoint] [%d] [%d] [119] add clues:1:234,3432 +[pinpoint] [%d] [%d] [119] add clues:2:234 +[pinpoint] [%d] [%d] [119] pinpoint_end_trace Done! +128 +[pinpoint] [%d] [%d] [128] pinpoint_start child [118] +118 +[pinpoint] [%d] [%d] [118] add clue key:name value:Foo +[pinpoint] [%d] [%d] [118] add clues:1:234,3432 +[pinpoint] [%d] [%d] [118] add clues:2:234 +[pinpoint] [%d] [%d] [118] pinpoint_end_trace Done! +128 +[pinpoint] [%d] [%d] [128] add clue key:args value:a,$b +[pinpoint] [%d] [%d] [128] add clue key:ret value:a,$b +[pinpoint] [%d] [%d]this span:({":E":%d,":FT":1500,":S":%d,"args":"a,$b","calls":[{":E":%d,":S":%d,"clues":["1:234,3432","2:234"],"name":"Foo"},{":E":%d,":S":%d,"clues":["1:234,3432","2:234"],"name":"Foo"},{":E":%d,":S":%d,"clues":["1:234,3432","2:234"],"name":"Foo"},{":E":%d,":S":%d,"clues":["1:234,3432","2:234"],"name":"Foo"},{":E":%d,":S":%d,"clues":["1:234,3432","2:234"],"name":"Foo"},{":E":%d,":S":%d,"clues":["1:234,3432","2:234"],"name":"Foo"},{":E":%d,":S":%d,"clues":["1:234,3432","2:234"],"name":"Foo"},{":E":%d,":S":%d,"clues":["1:234,3432","2:234"],"name":"Foo"},{":E":%d,":S":%d,"clues":["1:234,3432","2:234"],"name":"Foo"},{":E":%d,":S":%d,"clues":["1:234,3432","2:234"],"name":"Foo"}],"name":"ouput_234","ret":"a,$b"}) +[pinpoint] [%d] [%d]agent try to connect:(localhost:10000) +[pinpoint] [%d] [%d] [128] pinpoint_end_trace Done! +0 \ No newline at end of file diff --git a/tests_macos/trace_api_with_id.phpt b/tests_macos/trace_api_with_id.phpt new file mode 100644 index 00000000..0393917b --- /dev/null +++ b/tests_macos/trace_api_with_id.phpt @@ -0,0 +1,65 @@ +--TEST-- +Test pinpoint_unique_id +--SKIPIF-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=-1 +pinpoint_php.UnitTest=true +pinpoint_php.DebugReport=true +--FILE-- +getMessage(),$id); + + do + { + $lastId = _pinpoint_end_trace($lastId); + }while($lastId != 0); + echo "Uncaught exception: " , $exception->getMessage(), "\n"; +} + +set_exception_handler('exception_handler'); + +$id = _pinpoint_start_trace($id); +_pinpoint_add_clue("name","Foo",$id); +$id = _pinpoint_start_trace($id); +_pinpoint_add_clues("name","Foo1",$id); +$id = _pinpoint_start_trace($id); +_pinpoint_add_clue("name","Foo2",$id); +$id = _pinpoint_end_trace($id); +$id = _pinpoint_start_trace($id); +_pinpoint_add_clues("name","Foo3",$id); +_pinpoint_add_clue("name","Foo4",$id); +$id = _pinpoint_end_trace($id); +_pinpoint_add_clues("name","Foo5",$id); +throw new Exception("too heavy, throw it"); +$id = _pinpoint_end_trace($id); +_pinpoint_add_clue("name","Foo",$id); + +$id = _pinpoint_end_trace($id); + +--EXPECTF-- +[pinpoint] [%d] [%d] [0] pinpoint_start child [128] +[pinpoint] [%d] [%d] [128] add clue key:name value:Foo +[pinpoint] [%d] [%d] [128] pinpoint_start child [127] +[pinpoint] [%d] [%d] [127] add clues:name:Foo1 +[pinpoint] [%d] [%d] [127] pinpoint_start child [126] +[pinpoint] [%d] [%d] [126] add clue key:name value:Foo2 +[pinpoint] [%d] [%d] [126] pinpoint_end_trace Done! +[pinpoint] [%d] [%d] [127] pinpoint_start child [125] +[pinpoint] [%d] [%d] [125] add clues:name:Foo3 +[pinpoint] [%d] [%d] [125] add clue key:name value:Foo4 +[pinpoint] [%d] [%d] [125] pinpoint_end_trace Done! +[pinpoint] [%d] [%d] [127] add clues:name:Foo5 +[pinpoint] [%d] [%d] [127] add clue key:EXP value:too heavy, throw it +[pinpoint] [%d] [%d] [127] pinpoint_end_trace Done! +[pinpoint] [%d] [%d]this span:({":E":%d,":FT":1500,":S":%d,"calls":[{":E":%d,":S":%d,"EXP":"too heavy, throw it","calls":[{":E":%d,":S":%d,"name":"Foo2"},{":E":%d,":S":%d,"clues":["name:Foo3"],"name":"Foo4"}],"clues":["name:Foo1","name:Foo5"]}],"name":"Foo"}) +[pinpoint] [%d] [%d][unittest] current span was dropped +[pinpoint] [%d] [%d] [128] pinpoint_end_trace Done! +Uncaught exception: too heavy, throw it \ No newline at end of file diff --git a/tests_macos/trace_limit_test-i448.phpt b/tests_macos/trace_limit_test-i448.phpt new file mode 100644 index 00000000..8cabc233 --- /dev/null +++ b/tests_macos/trace_limit_test-i448.phpt @@ -0,0 +1,48 @@ +--TEST-- +Check tracelimit +--SKIPIF-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=200 +pinpoint_php.UnitTest=true +pinpoint_php.TraceLimit=0 +;pinpoint_php._limit for internal use. does not use it +pinpoint_php._limit=yes +pinpoint_php.DebugReport=true +--FILE-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=200 +pinpoint_php.UnitTest=true +pinpoint_php.TraceLimit=2 +;pinpoint_php._limit for internal use. User do not use it +pinpoint_php._limit=yes +pinpoint_php.DebugReport=true +--FILE-- + +--INI-- +pinpoint_php.CollectorHost=tcp:localhost:10000 +pinpoint_php.SendSpanTimeOutMs=0 +pinpoint_php.UnitTest=true +pinpoint_php.DebugReport=true +--FILE-- + Date: Wed, 31 Jul 2024 11:42:55 +0800 Subject: [PATCH 20/24] update doc --- CHANGES-PHP.md | 5 +++++ DOC/PHP/Readme.md | 18 +++++++++--------- package.xml | 26 ++++++++++++++++++++------ 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/CHANGES-PHP.md b/CHANGES-PHP.md index 3e6fb8e0..354d17c8 100644 --- a/CHANGES-PHP.md +++ b/CHANGES-PHP.md @@ -1,3 +1,8 @@ +## 0.5.3 2024-07-31 +- build on win32 +- build on macos +- support SendSpanTimeOutMs=-1 + ## 0.5.2 2024-05-30 - add pinpoint_get_caller_arg diff --git a/DOC/PHP/Readme.md b/DOC/PHP/Readme.md index 44c7e117..6c6aac53 100644 --- a/DOC/PHP/Readme.md +++ b/DOC/PHP/Readme.md @@ -6,21 +6,21 @@ ### Requirement -Dependency|Version| More ----|----|---- -PHP| php `7+`| -GCC| GCC `4.7+`| C++11 -*inux|| `windows is on the way` -pinpoint| `2.0+`| -composer| | class can be automatic pinpoint-cut -collector-agent| [installed ?](../collector-agent/readme.md) +| Dependency | Version | More | +| ------------------- | ------------------------------------------- | ----------------------------------- | +| PHP | php `7+` | +| GCC | GCC `4.7+` | C++11 | +| *inux/windows/macOs | | `windows is on the way` | +| pinpoint | `2.0+` | +| composer | | class can be automatic pinpoint-cut | +| collector-agent | [installed ?](../collector-agent/readme.md) | ### Installation #### Steps 1. Install `ext-pinpoint_php` - curl -sL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/v0.6.0/install_pinpoint_php.sh | sh + curl -sL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/latest/install_pinpoint_php.sh | sh 2. Check your pinpoint_php.ini is right diff --git a/package.xml b/package.xml index 54d66e65..83489710 100644 --- a/package.xml +++ b/package.xml @@ -21,18 +21,21 @@ http://pear.php.net/dtd/package-2.0.xsd"> dl_cd_pinpoint@navercorp.com yes - 2024-07-29 + 2024-08-07 - 0.5.2 - 0.5.2 + 0.5.3 + 0.5.3 - stable - stable + alpha + alpha Apache License 2.0 - https://github.com/pinpoint-apm/pinpoint-c-agent + ## 0.5.3 2024-07-31 + - build on win32 + - build on macos + - support SendSpanTimeOutMs=-1 @@ -114,6 +117,17 @@ http://pear.php.net/dtd/package-2.0.xsd"> + + alphaalpha + 0.5.20.5.2 + 2024-07-29 + + ## What's Changed + - add pinpoint_get_caller_arg + + **Full Changelog**: https://github.com/pinpoint-apm/pinpoint-c-agent/compare/v0.5.0...v0.6.0 + + stablestable 0.5.20.5.2 From acb2b9ece10ab4a12659248dad3af9e3a12353f4 Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:00:07 +0800 Subject: [PATCH 21/24] update package.xml --- package.xml | 266 +++++++++++++++++++++++++++------------------------- 1 file changed, 140 insertions(+), 126 deletions(-) diff --git a/package.xml b/package.xml index 83489710..1d4c6602 100644 --- a/package.xml +++ b/package.xml @@ -1,14 +1,15 @@ - - pinpoint_php - pecl.php.net - PHP extension for pinpoint-apm - - This extension provides an API pinpoint-apm and built-in function auto-injection - + + pinpoint_php + pecl.php.net + PHP extension for pinpoint-apm + + This extension provides an API pinpoint-apm and built-in function auto-injection + Jason Mile eeliu @@ -21,124 +22,137 @@ http://pear.php.net/dtd/package-2.0.xsd"> dl_cd_pinpoint@navercorp.com yes - 2024-08-07 - - 0.5.3 - 0.5.3 - - - alpha - alpha - - Apache License 2.0 - - ## 0.5.3 2024-07-31 - - build on win32 - - build on macos - - support SendSpanTimeOutMs=-1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 2024-08-07 + + 0.5.3 + 0.5.3 + + + alpha + alpha + + Apache License 2.0 + + ## 0.5.3 2024-07-31 + - build on win32 + - build on macos + - support SendSpanTimeOutMs=-1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - 7.1.0 - - - 1.4.0b1 - - - - pinpoint_php - - - - - alphaalpha - 0.5.20.5.2 - 2024-07-29 - - ## What's Changed - - add pinpoint_get_caller_arg - - **Full Changelog**: https://github.com/pinpoint-apm/pinpoint-c-agent/compare/v0.5.0...v0.6.0 - - - - stablestable - 0.5.20.5.2 - 2024-07-29 - - ## What's Changed - - add pinpoint_get_caller_arg + + + + + 7.1.0 + + + 1.4.0b1 + + + + pinpoint_php + + + + + + alpha + alpha + + + 0.5.3 + 0.5.3 + + 2024-08-07 + + ## What's Changed + ## 0.5.3 2024-07-31 + - build on win32 + - build on macos + - support SendSpanTimeOutMs=-1 + + + + + stable + stable + + + 0.5.2 + 0.5.2 + + 2024-07-29 + + ## What's Changed + - add pinpoint_get_caller_arg - **Full Changelog**: https://github.com/pinpoint-apm/pinpoint-c-agent/compare/v0.5.0...v0.6.0 - - + **Full Changelog**: https://github.com/pinpoint-apm/pinpoint-c-agent/compare/v0.5.0...v0.6.0 + + - + \ No newline at end of file From f5438d111c7beffbc2a66837320cee3781d2f40c Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Wed, 31 Jul 2024 15:35:25 +0800 Subject: [PATCH 22/24] add windows --- .github/workflows/main.yml | 34 ++++++++++++++++++++-------------- DOC/PHP/Readme-CN.md | 15 +++++++-------- DOC/PHP/Readme-KR.md | 15 +++++++-------- DOC/PHP/Readme.md | 3 +-- 4 files changed, 35 insertions(+), 32 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c6b624dc..70ca5833 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -167,35 +167,39 @@ jobs: - name: package run: | - Move-Item -Path output/Release/php_pinpoint_php.* -Destination . -ErrorAction SilentlyContinue - Move-Item -Path output/Release_TS/php_pinpoint_php.* -Destination . -ErrorAction SilentlyContinue - + mkdir _package_ + cp output/Release/php_pinpoint_php.* _package_ -ErrorAction SilentlyContinue + cp output/Release_TS/php_pinpoint_php.* _package_ -ErrorAction SilentlyContinue + cp NOTICE _package_ + cp README.md _package_ + cp CHANGES-PHP.md _package_ + cp LICENSE _package_ + Compress-Archive -Path _package_/* ${{ env.pinpoint_php_win32_pack_name }}.zip - uses: actions/upload-artifact@v4 with: name: ${{ env.pinpoint_php_win32_pack_name }} - path: | - php_pinpoint_php.dll - php_pinpoint_php.lib - php_pinpoint_php.pdb - NOTICE - README.md - CHANGES-PHP.md - LICENSE + path: ${{ env.pinpoint_php_win32_pack_name }}.zip retention-days: 5 overwrite: true if-no-files-found: error + PHP-Release-Win32-Package: + needs: [ PHP-Win-2019, pack_php_module] + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + steps: - name: Download All Artifacts uses: actions/download-artifact@v4 - if: startsWith(github.ref, 'refs/tags/') with: - name: ${{ env.pinpoint_php_win32_pack_name }} + # name: ${{ env.pinpoint_php_win32_pack_name }} path: pinpoint-artifact + pattern: pinpoint_php-* + merge-multiple: true + - run: ls -R pinpoint-artifact - name: Release php_package id: rel_php_pak uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') with: files: pinpoint-artifact/* @@ -283,6 +287,8 @@ jobs: - name: Setup protoc uses: arduino/setup-protoc@v2.1.0 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} - name: run unittest run: | diff --git a/DOC/PHP/Readme-CN.md b/DOC/PHP/Readme-CN.md index 59fdce8f..ca55e801 100644 --- a/DOC/PHP/Readme-CN.md +++ b/DOC/PHP/Readme-CN.md @@ -2,14 +2,13 @@ ### 依赖组件 -Dependency|Version| More ----|----|---- -PHP| php `7+`| -GCC| GCC `4.7+`| C++11 -*inux|| `windows is on the way` -pinpoint| `2.0+`| -composer| | class can be automatic pinpoint-cut -collector-agent| [installed ?](../collector-agent/readme.md) +| Dependency | Version | More | +| ------------------- | ------------------------------------------- | ----------------------------------- | +| PHP | php `7+` | +| *inux/windows/macOs | | windows is released | +| pinpoint | `2.0+` | +| composer | | class can be automatic pinpoint-cut | +| collector-agent | [installed ?](../collector-agent/readme.md) | ### 安装步骤 diff --git a/DOC/PHP/Readme-KR.md b/DOC/PHP/Readme-KR.md index 10c98ee4..d3f7e889 100644 --- a/DOC/PHP/Readme-KR.md +++ b/DOC/PHP/Readme-KR.md @@ -2,14 +2,13 @@ ### 요구 -디펜던시 | 버전 | 부가 ----|----|---- -PHP| php `7+`| -GCC| GCC `4.7+`| C++11 -*inux|| `windows is on the way` -pinpoint| `2.0+`| -composer| | class can be automatic pinpoint-cut -collector-agent| [installed ?](../collector-agent/readme.md) +| 디펜던시 | 버전 | 부가 | +| ------------------- | ------------------------------------------- | ----------------------------------- | +| PHP | php `7+` | +| *inux/windows/macOs | | windows is released | +| pinpoint | `2.0+` | +| composer | | class can be automatic pinpoint-cut | +| collector-agent | [installed ?](../collector-agent/readme.md) | ### 설치 스텝 diff --git a/DOC/PHP/Readme.md b/DOC/PHP/Readme.md index 6c6aac53..29c68d53 100644 --- a/DOC/PHP/Readme.md +++ b/DOC/PHP/Readme.md @@ -9,8 +9,7 @@ | Dependency | Version | More | | ------------------- | ------------------------------------------- | ----------------------------------- | | PHP | php `7+` | -| GCC | GCC `4.7+` | C++11 | -| *inux/windows/macOs | | `windows is on the way` | +| *inux/windows/macOs | | windows is released | | pinpoint | `2.0+` | | composer | | class can be automatic pinpoint-cut | | collector-agent | [installed ?](../collector-agent/readme.md) | From c3f7427d680d184db73573f77ef47e51c447c6e1 Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Thu, 1 Aug 2024 11:21:20 +0800 Subject: [PATCH 23/24] fix package --- .github/workflows/main.yml | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 70ca5833..b34c2991 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -74,10 +74,12 @@ jobs: --log-file=valgrind-out.txt \ ./bin/TestCommon - name: Archive docs - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: valgrind-out path: common/build/valgrind-out.txt + retention-days: 5 + if-no-files-found: error PHP: runs-on: ubuntu-latest @@ -153,7 +155,6 @@ jobs: run: | php -m php -v - where.exe php mkdir output phpize ./configure.bat --enable-pinpoint_php --enable-debug-pack --enable-object-out-dir=output --with-prefix=${{steps.setup-php-sdk.outputs.prefix}} @@ -168,8 +169,18 @@ jobs: - name: package run: | mkdir _package_ - cp output/Release/php_pinpoint_php.* _package_ -ErrorAction SilentlyContinue - cp output/Release_TS/php_pinpoint_php.* _package_ -ErrorAction SilentlyContinue + if (Test-Path -Path output/Release/ -PathType Container) { + cp output/Release/php_pinpoint_php.dll _package_ + cp output/Release/php_pinpoint_php.pdb _package_ + cp output/Release/php_pinpoint_php.lib _package_ + } + + if (Test-Path -Path output/Release_TS/ -PathType Container) { + cp output/Release_TS/php_pinpoint_php.dll _package_ + cp output/Release_TS/php_pinpoint_php.pdb _package_ + cp output/Release_TS/php_pinpoint_php.lib _package_ + } + cp NOTICE _package_ cp README.md _package_ cp CHANGES-PHP.md _package_ @@ -180,7 +191,6 @@ jobs: name: ${{ env.pinpoint_php_win32_pack_name }} path: ${{ env.pinpoint_php_win32_pack_name }}.zip retention-days: 5 - overwrite: true if-no-files-found: error PHP-Release-Win32-Package: @@ -191,9 +201,8 @@ jobs: - name: Download All Artifacts uses: actions/download-artifact@v4 with: - # name: ${{ env.pinpoint_php_win32_pack_name }} path: pinpoint-artifact - pattern: pinpoint_php-* + pattern: pinpoint_php* merge-multiple: true - run: ls -R pinpoint-artifact @@ -225,10 +234,12 @@ jobs: # mv ${{ env.MODULE_PAK }} $pinpoint_php_win32_pack_name # echo "PACK=$pinpoint_php_win32_pack_name" >> $GITHUB_OUTPUT - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: - name: ${{ env.MODULE_PAK }} + name: pinpoint_php.tgz path: pinpoint_php*.tgz + retention-days: 5 + if-no-files-found: error Python: strategy: From 5c903b7cebf3ced5b78a69c7729b74241df8479f Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Thu, 1 Aug 2024 13:33:07 +0800 Subject: [PATCH 24/24] update doc --- DOC/PHP/Readme-CN.md | 7 ++++++- DOC/PHP/Readme-KR.md | 7 ++++++- DOC/PHP/Readme.md | 6 +++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/DOC/PHP/Readme-CN.md b/DOC/PHP/Readme-CN.md index ca55e801..6bab2bcb 100644 --- a/DOC/PHP/Readme-CN.md +++ b/DOC/PHP/Readme-CN.md @@ -14,7 +14,12 @@ 1. 安装 `ext-pinpoint_php` 模块 - curl -sL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/v0.6.0/install_pinpoint_php.sh | sh + `pecl install pinpoint_php` + or + `curl -sL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/latest/install_pinpoint_php.sh | sh` + + > On windows: download .dll from https://pecl.php.net/package/pinpoint_php or https://github.com/pinpoint-apm/pinpoint-c-agent/releases/latest + 2. 检查下你的配置文件 pinpoint_php.ini diff --git a/DOC/PHP/Readme-KR.md b/DOC/PHP/Readme-KR.md index d3f7e889..1fad0ca0 100644 --- a/DOC/PHP/Readme-KR.md +++ b/DOC/PHP/Readme-KR.md @@ -13,7 +13,12 @@ ### 설치 스텝 1. `ext-pinpoint_php` 모듈 설치 - curl -sL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/v0.6.0/install_pinpoint_php.sh | sh + + `pecl install pinpoint_php` + or + `curl -sL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/latest/install_pinpoint_php.sh | sh` + + > On windows: download .dll from https://pecl.php.net/package/pinpoint_php or https://github.com/pinpoint-apm/pinpoint-c-agent/releases/latest 2. pinpoint_php.ini 설정 파일 확인 ```ini diff --git a/DOC/PHP/Readme.md b/DOC/PHP/Readme.md index 29c68d53..14a8916c 100644 --- a/DOC/PHP/Readme.md +++ b/DOC/PHP/Readme.md @@ -19,7 +19,11 @@ #### Steps 1. Install `ext-pinpoint_php` - curl -sL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/latest/install_pinpoint_php.sh | sh + `pecl install pinpoint_php` + or + `curl -sL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/latest/install_pinpoint_php.sh | sh` + + > On windows: download .dll from https://pecl.php.net/package/pinpoint_php or https://github.com/pinpoint-apm/pinpoint-c-agent/releases/latest 2. Check your pinpoint_php.ini is right