diff --git a/.github/workflows/publish-collector-agent.yml b/.github/workflows/publish-collector-agent.yml index 5720b459..a6bd3f7d 100644 --- a/.github/workflows/publish-collector-agent.yml +++ b/.github/workflows/publish-collector-agent.yml @@ -3,6 +3,7 @@ name: publish-collector-agent on: release: types: [created] + workflow_dispatch: permissions: contents: write @@ -10,7 +11,7 @@ permissions: env: REGISTRY_IMAGE: ghcr.io/${{ github.repository }}/collector-agent - TAG_NAME: ${{ github.head_ref || github.ref_name }} + TAG_NAME: 0.7 jobs: collector-agent: @@ -58,9 +59,6 @@ jobs: with: context: collector-agent platforms: ${{ matrix.platform }} - # tags: | - # ghcr.io/${{ github.repository }}/collector-agent:${{ inputs.tag }} - # ghcr.io/${{ github.repository }}/collector-agent:latest github-token: ${{ secrets.GITHUB_TOKEN }} labels: ${{ steps.meta.outputs.labels }} outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true @@ -115,10 +113,11 @@ jobs: - name: Inspect image run: | - docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} + docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ env.TAG_NAME }} Release-Collector-agent: runs-on: ubuntu-latest + if: github.event_name == 'release' strategy: matrix: # build and publish in parallel: linux/386, linux/amd64, linux/arm64, windows/386, windows/amd64, darwin/amd64, darwin/arm64 @@ -132,7 +131,7 @@ jobs: id: release-ca with: github_token: ${{ secrets.GITHUB_TOKEN }} - goversion: "https://dl.google.com/go/go1.18.10.linux-amd64.tar.gz" + goversion: 1.19 goos: ${{ matrix.goos }} goarch: ${{ matrix.goarch }} project_path: "collector-agent" diff --git a/.gitignore b/.gitignore index 50e51cc3..505fa967 100644 --- a/.gitignore +++ b/.gitignore @@ -84,4 +84,5 @@ x86 output config.nice.bat configure.bat -configure.js \ No newline at end of file +configure.js +*.cap \ No newline at end of file diff --git a/DOC/C-CPP/Readme.md b/DOC/C-CPP/Readme.md index 98f780e9..3d5d7483 100644 --- a/DOC/C-CPP/Readme.md +++ b/DOC/C-CPP/Readme.md @@ -20,20 +20,11 @@ While, check examples `src/CPP/test_pinpoint.cpp` and `src/CPP/test_pinpoint.c`. ```shell include(FetchContent) + FetchContent_Declare( - pinpoint - GIT_REPOSITORY https://github.com/pinpoint-c-agent/pinpoint-c-agent.git - # GIT_TAG 74bc39d813d664cb56b78b1506d91932c8131396 - # not recommended, please use hash key like `74bc39d813d664cb56b78b1506d91932c8131396` - GIT_TAG origin/v0.5.0 + pinpoint + URL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/v0.7/pinpoint-common.tar.gz ) - -FetchContent_GetProperties(pinpoint) -if (NOT pinpoint_POPULATED) - FetchContent_Populate(pinpoint) - add_subdirectory(${pinpoint_SOURCE_DIR}/common ${pinpoint_BINARY_DIR}) -endif () - FetchContent_MakeAvailable(pinpoint) add_executable(app test_pinpoint.cpp) diff --git a/DOC/collector-agent/Readme-CN.md b/DOC/collector-agent/Readme-CN.md index d5ab9368..61889f71 100644 --- a/DOC/collector-agent/Readme-CN.md +++ b/DOC/collector-agent/Readme-CN.md @@ -39,7 +39,7 @@ pinpoint-collector的桥接模块 #### 例子: ```sh -docker run -itd -p 9999:9999 --env-file ./env.list ghcr.io/pinpoint-apm/pinpoint-c-agent/collector-agent:latest +docker run -itd -p 9999:9999 --env-file ./env.list ghcr.io/pinpoint-apm/pinpoint-c-agent/collector-agent:0.7 ``` ### 3. K8S 中以sidecar 模式运行 @@ -47,7 +47,7 @@ docker run -itd -p 9999:9999 --env-file ./env.list ghcr.io/pinpoint-apm/pinpoin server.yaml sample ``` yml -- image: ghcr.io/pinpoint-apm/pinpoint-c-agent/collector-agent:v0.6.4 +- image: ghcr.io/pinpoint-apm/pinpoint-c-agent/collector-agent:0.7 name: collector-agent args: ["-RecvBufSize=1048576"] securityContext: @@ -75,7 +75,7 @@ server.yaml sample ### 4. 手动编译 [require `go.1.18`] -- 执行: `GOBIN=/usr/local/bin/ go install github.com/pinpoint-apm/pinpoint-c-agent/collector-agent@dev` +- 执行: `GOBIN=/usr/local/bin/ go install github.com/pinpoint-apm/pinpoint-c-agent/collector-agent@0.7` - ❗❗❗Note: collector-agent: located into `/usr/local/bin/` `./collector-agent` diff --git a/DOC/collector-agent/Readme-KR.md b/DOC/collector-agent/Readme-KR.md index 3c1a87c1..806baa04 100644 --- a/DOC/collector-agent/Readme-KR.md +++ b/DOC/collector-agent/Readme-KR.md @@ -39,7 +39,7 @@ pinpoint-collector의 브리지 모듈 #### 예시: ```sh -docker run -itd -p 9999:9999 --env-file ./env.list ghcr.io/pinpoint-apm/pinpoint-c-agent/collector-agent:latest +docker run -itd -p 9999:9999 --env-file ./env.list ghcr.io/pinpoint-apm/pinpoint-c-agent/collector-agent:0.7 ``` ### 3. K8S에서 sidecar 모드로 실행 @@ -47,7 +47,7 @@ docker run -itd -p 9999:9999 --env-file ./env.list ghcr.io/pinpoint-apm/pinpoin server.yaml sample ``` yml -- image: ghcr.io/pinpoint-apm/pinpoint-c-agent/collector-agent:v0.6.4 +- image: ghcr.io/pinpoint-apm/pinpoint-c-agent/collector-agent:0.7 name: collector-agent args: ["-RecvBufSize=1048576"] securityContext: @@ -75,7 +75,7 @@ server.yaml sample ### 4. 수동 컴파일 [require `go.1.18`] -- 실행: `GOBIN=/usr/local/bin/ go install github.com/pinpoint-apm/pinpoint-c-agent/collector-agent@dev` +- 실행: `GOBIN=/usr/local/bin/ go install github.com/pinpoint-apm/pinpoint-c-agent/collector-agent@0.7` - ❗❗❗Note: collector-agent: located into `/usr/local/bin/` `./collector-agent` diff --git a/DOC/collector-agent/Readme.md b/DOC/collector-agent/Readme.md index e4ff323f..f3d3d50f 100644 --- a/DOC/collector-agent/Readme.md +++ b/DOC/collector-agent/Readme.md @@ -39,7 +39,7 @@ A bridger to pinpoint-collector. #### Example: ```sh -docker run -itd -p 9999:9999 --env-file ./env.list ghcr.io/pinpoint-apm/pinpoint-c-agent/collector-agent:latest +docker run -itd -p 9999:9999 --env-file ./env.list ghcr.io/pinpoint-apm/pinpoint-c-agent/collector-agent:0.7 ``` ### 3. K8s side car @@ -47,7 +47,7 @@ docker run -itd -p 9999:9999 --env-file ./env.list ghcr.io/pinpoint-apm/pinpoin server.yaml sample ``` yml -- image: ghcr.io/pinpoint-apm/pinpoint-c-agent/collector-agent:v0.6.4 +- image: ghcr.io/pinpoint-apm/pinpoint-c-agent/collector-agent:0.7 name: collector-agent args: ["-RecvBufSize=1048576"] securityContext: @@ -75,7 +75,7 @@ server.yaml sample ### 4. Compiling from source [require `go.1.18`] -- Install: `GOBIN=/usr/local/bin/ go install github.com/pinpoint-apm/pinpoint-c-agent/collector-agent@dev` +- Install: `GOBIN=/usr/local/bin/ go install github.com/pinpoint-apm/pinpoint-c-agent/collector-agent@v0.7` - ❗❗❗Note: collector-agent: located into `/usr/local/bin/` `./collector-agent` diff --git a/collector-agent/1.cap b/collector-agent/1.cap deleted file mode 100644 index bfd93f5b..00000000 Binary files a/collector-agent/1.cap and /dev/null differ diff --git a/collector-agent/common/config.go b/collector-agent/common/config.go index cb392dd2..8c446601 100644 --- a/collector-agent/common/config.go +++ b/collector-agent/common/config.go @@ -28,7 +28,6 @@ type UserSetting struct { LoggerLevel string LoggerDir string LogStdout bool - Profile bool } func (u *UserSetting) String() string { diff --git a/collector-agent/makefile b/collector-agent/makefile index 34fe96a5..9b4cb0ea 100644 --- a/collector-agent/makefile +++ b/collector-agent/makefile @@ -1,5 +1,5 @@ -TAG ?=v0.6.4 +TAG ?=v0.7 .PHONY: default default: server ; diff --git a/collector-agent/server.go b/collector-agent/server.go index e775c57f..f67d7d5b 100644 --- a/collector-agent/server.go +++ b/collector-agent/server.go @@ -25,6 +25,7 @@ var ( log_level = flag.String("LogLevel", "debug", "Set logging output level(debug/info/warn/error); eg: -LogLevel=info") server_recv_buf = flag.Int("RecvBufSize", 4096*100, "Set recv buf; eg: -RecvBufSize=409600") enable_profile = flag.Bool("EnableProfile", false, "enable net/http/pprof") + show_version = flag.Bool("v", false, "show current version and exit") ) func parseConfig() *common.Config { @@ -38,7 +39,6 @@ func parseConfig() *common.Config { LoggerLevel: *log_level, LogStdout: *log_stdout, LoggerDir: *log_dir, - Profile: *enable_profile, } if ip, ok := os.LookupEnv("PP_COLLECTOR_AGENT_SPAN_IP"); ok { if port, ok := os.LookupEnv("PP_COLLECTOR_AGENT_SPAN_PORT"); ok { @@ -87,7 +87,12 @@ func main() { config := parseConfig() - if config.User.Profile { + if *show_version { + fmt.Fprintf(os.Stderr, "collector-agent:%s \r\n", server.Version) + return + } + + if *enable_profile { go func() { log.Println(http.ListenAndServe("0.0.0.0:8081", nil)) runtime.SetBlockProfileRate(1) diff --git a/collector-agent/server/Server.go b/collector-agent/server/Server.go index 62dc0e7d..6d60b5c6 100644 --- a/collector-agent/server/Server.go +++ b/collector-agent/server/Server.go @@ -20,7 +20,7 @@ import ( "github.com/sirupsen/logrus" ) -var Version = "v0.6.4" +var Version = "0.7" type Server struct { listener net.Listener diff --git a/common/CHANGES.md b/common/CHANGES.md index 96b3ebee..7fdfa940 100644 --- a/common/CHANGES.md +++ b/common/CHANGES.md @@ -1,4 +1,4 @@ -## v0.6.0 +## v0.6.0 2024-10-10 - refactor span json protocol - add async api - data structure change: multiple map to list diff --git a/common/readme.md b/common/readme.md index 67961361..8aa81a45 100644 --- a/common/readme.md +++ b/common/readme.md @@ -4,6 +4,6 @@ ```shell $ cmake -DWITH_TEST_CASE=1 -DWITH_CODECOVERAGE=1 -DCMAKE_BUILD_TYPE=Debug .. -$ ./bin/TestCommon --gtest_filter=node.wakeTrace +$ ./bin/TestCommon ``` diff --git a/testapps/cpp/pinpoint_helper.h b/testapps/cpp/pinpoint_helper.h index 59607e9f..508ab381 100644 --- a/testapps/cpp/pinpoint_helper.h +++ b/testapps/cpp/pinpoint_helper.h @@ -24,6 +24,7 @@ #include #include +// per-thread context id static thread_local NodeID local_node_id = E_ROOT_NODE; namespace pinpoint { @@ -60,7 +61,7 @@ async(F &&f, Args &&... args) { E_LOC_CURRENT); pinpoint_add_clue(local_node_id, PP_SERVER_TYPE, PP_INVOCATION_CALL_TYPE, E_LOC_CURRENT); - + // a random number for avoiding ID collision int32_t async_id = random() % 99999; std::string async_id_str = std::to_string(async_id); pinpoint_add_clue(local_node_id, PP_ASYNC_CALL_ID, async_id_str.c_str(), @@ -79,12 +80,12 @@ async(F &&f, Args &&... args) { size = pinpoint_get_context_key(local_node_id, PP_SPAN_ID, buf, 128); std::string sid(buf, size); - + // get the root trace tid and span id size = pinpoint_get_context_key(local_node_id, PP_APP_NAME, buf, 128); std::string app_name(buf, size); size = pinpoint_get_context_key(local_node_id, PP_APP_ID, buf, 128); std::string app_id(buf, size); - + // wrapper user function (F) with pinpoint_wrapper_func auto pinpoint_wrapper_func = [=]() -> return_type { local_node_id = pinpoint_start_trace(local_node_id); pinpoint_add_clue(local_node_id, PP_APP_NAME, app_name.c_str(), @@ -97,6 +98,7 @@ async(F &&f, Args &&... args) { pinpoint_add_clue(local_node_id, PP_SERVER_TYPE, PP_C_CPP_METHOD, E_LOC_CURRENT); + // mark current span as a asynchronous span pinpoint_set_async_ctx(local_node_id, async_id, sequence_id); (*task)(); local_node_id = pinpoint_end_trace(local_node_id); @@ -104,6 +106,7 @@ async(F &&f, Args &&... args) { }; auto async_res = std::async(std::launch::async, pinpoint_wrapper_func); + // end current trace local_node_id = pinpoint_end_trace(local_node_id); return async_res; }