Skip to content

Commit

Permalink
Pre release 0.4.13 (#563)
Browse files Browse the repository at this point in the history
* update common version id 
* add test for #562
* fix useless fail
* fix backend crash
  • Loading branch information
eeliu committed Mar 28, 2024
1 parent e836155 commit 1e49471
Show file tree
Hide file tree
Showing 56 changed files with 1,322 additions and 426 deletions.
5 changes: 1 addition & 4 deletions DOC/collector-agent/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@
### Use docker images
```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.4.25
```

> Collector Agent Span Specification
[Json string map to Pinpoint item](../API/collector-agent/Readme.md)


32 changes: 3 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![pinpoint](images/logo.png)

[![Build](https://github.com/pinpoint-apm/pinpoint-c-agent/workflows/Build/badge.svg?branch=master)](https://github.com/pinpoint-apm/pinpoint-c-agent/actions) [![Gitter](https://badges.gitter.im/naver/pinpoint-c-agent.svg)](https://gitter.im/naver/pinpoint-c-agent?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![codecov](https://codecov.io/gh/pinpoint-apm/pinpoint-c-agent/branch/master/graph/badge.svg?token=KswbmFvWp3)](https://codecov.io/gh/pinpoint-apm/pinpoint-c-agent) [![License](https://img.shields.io/github/license/pinpoint-apm/pinpoint-c-agent)](LICENSE)
[![CI](https://github.com/pinpoint-apm/pinpoint-c-agent/actions/workflows/main.yml/badge.svg)](https://github.com/pinpoint-apm/pinpoint-c-agent/actions/workflows/main.yml) [![Gitter](https://badges.gitter.im/naver/pinpoint-c-agent.svg)](https://gitter.im/naver/pinpoint-c-agent?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![codecov](https://codecov.io/gh/pinpoint-apm/pinpoint-c-agent/branch/master/graph/badge.svg?token=KswbmFvWp3)](https://codecov.io/gh/pinpoint-apm/pinpoint-c-agent) [![License](https://img.shields.io/github/license/pinpoint-apm/pinpoint-c-agent)](LICENSE)



Expand All @@ -9,42 +9,18 @@

The current stable version is [the Latest](https://github.com/pinpoint-apm/pinpoint-c-agent/releases).

# Pinpoint Common Agent
# Pinpoint Agent

It is an agent written by C++, PHP and Python languages. And we hope to support other languages by this agent. Until now, it supports **_PHP_**, **_C/CPP_** and **_PYTHON_**.

## Overview Pinpoint Common Agent
## Overview Pinpoint Agent

### How does it work

![How does it work](images/pinpoint_v0.5.x.png)

### Distributed Tracking system

![php_agent_example](images/php_agent_example.png)

### Call Stack

![php_agent_example_detail](images/php_agent_example_detail.png) | ![php_agent_example_memcached](images/callstack-memcached.png)
--- | ---
![php_agent_example_pdo](images/callstack-pdo.png) | ![php_agent_example_redis](images/callstack-redis.png)

### Real-time Tracking Chart

CPU | Response Time
--- | ---
![php_agent_example_pdo](images/cpu.png) | ![php_agent_example_redis](images/responsetime.png)


## Installation guide

**Components:**
* Collector-Agent (**Required**)
* PHP-Agent
* Python-Agent
* c/cpp Agent
* Golang-Agent

### Install Collector-Agent

[How to install Collector-Agent](DOC/collector-agent/readme.md)
Expand Down Expand Up @@ -80,8 +56,6 @@ golang|[go-aop-agent](https://github.com/pinpoint-apm/go-aop-agent)

We are looking forward to your contributions via pull requests.

https://github.com/pinpoint-apm/pinpoint-c-agent/graphs/contributors

## License
This project is licensed under the Apache License, Version 2.0.
See [LICENSE](LICENSE) for full license text.
Expand Down
2 changes: 1 addition & 1 deletion collector-agent/agent/GrpcAgent.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (agent *GrpcAgent) sendStat() {
wg.Add(1)
go func() {
for {
msg := agent.utReport.MoveUtReprot()
msg := agent.utReport.MoveUtReport()

agent.log.Debugf("%v", msg)
if err := stream.Send(msg); err != nil {
Expand Down
22 changes: 11 additions & 11 deletions collector-agent/agent/UrlTemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (ust *uriStatHistogram) Update(span *TSpan) {
ust.TimestampHistogram[span.FindHistogramLevel()] += 1
}

func (ust *uriStatHistogram) ToUriHistogrm() *v1.PUriHistogram {
func (ust *uriStatHistogram) ToUriHistogram() *v1.PUriHistogram {
pbUriHistogram := &v1.PUriHistogram{
Total: ust.Total,
Max: ust.Max,
Expand All @@ -35,20 +35,20 @@ func (ust *uriStatHistogram) ToUriHistogrm() *v1.PUriHistogram {
return pbUriHistogram
}

type statHisograms struct {
type statHistograms struct {
TotalHistogram uriStatHistogram
FailedHistogram uriStatHistogram
}

func (st *statHisograms) Update(span *TSpan) {
func (st *statHistograms) Update(span *TSpan) {
st.TotalHistogram.Update(span)
if span.IsFailed() {
st.FailedHistogram.Update(span)
}
}

type UrlTemplateReport struct {
uriMap map[string]*statHisograms
uriMap map[string]*statHistograms
BucketVersion int32
mu sync.Mutex
}
Expand All @@ -65,16 +65,16 @@ func (utr *UrlTemplateReport) updateUriSnapshot(span *TSpan) {
utr.mu.Lock()
defer utr.mu.Unlock()
ut := span.UT
var st *statHisograms
var st *statHistograms
var ok bool
if st, ok = utr.uriMap[ut]; !ok {
st = &statHisograms{}
st = &statHistograms{}
utr.uriMap[ut] = st
}
st.Update(span)
}

func (utr *UrlTemplateReport) MoveUtReprot() *v1.PStatMessage {
func (utr *UrlTemplateReport) MoveUtReport() *v1.PStatMessage {
utr.mu.Lock()
defer utr.mu.Unlock()

Expand All @@ -85,14 +85,14 @@ func (utr *UrlTemplateReport) MoveUtReprot() *v1.PStatMessage {
for url, st := range utr.uriMap {
eachUriStat := &v1.PEachUriStat{
Uri: url,
TotalHistogram: st.TotalHistogram.ToUriHistogrm(),
FailedHistogram: st.FailedHistogram.ToUriHistogrm(),
TotalHistogram: st.TotalHistogram.ToUriHistogram(),
FailedHistogram: st.FailedHistogram.ToUriHistogram(),
Timestamp: time.Now().UnixMilli(),
}
agentUriStat.EachUriStat = append(agentUriStat.EachUriStat, eachUriStat)
}
//note: create a new one
utr.uriMap = make(map[string]*statHisograms)
utr.uriMap = make(map[string]*statHistograms)
pbStat := &v1.PStatMessage{
Field: &v1.PStatMessage_AgentUriStat{
AgentUriStat: agentUriStat,
Expand All @@ -104,7 +104,7 @@ func (utr *UrlTemplateReport) MoveUtReprot() *v1.PStatMessage {

func CreateUrlTemplateReport() *UrlTemplateReport {
ut := &UrlTemplateReport{
uriMap: make(map[string]*statHisograms),
uriMap: make(map[string]*statHistograms),
BucketVersion: bucketVersion,
}
return ut
Expand Down
4 changes: 2 additions & 2 deletions collector-agent/agent/UrlTemplate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestUrlTemplateReport(t *testing.T) {
t.Log(len(ut.uriMap))
}

pbStatMessage := ut.MoveUtReprot()
pbStatMessage := ut.MoveUtReport()
t.Log(pbStatMessage)
assert.NotEqual(t, pbStatMessage.GetAgentUriStat(), nil, "GetAgentUriStat")

Expand All @@ -57,6 +57,6 @@ func TestUrlTemplateReport(t *testing.T) {
totalHis := eachUriStat[0].GetTotalHistogram()
assert.Equal(t, len(totalHis.GetHistogram()), histogramSize, "len(totalHis.GetHistogram())")

assert.Equal(t, totalHis.Max, int64(3200), "totalHis.Max")
assert.GreaterOrEqual(t, totalHis.Max, int64(3200), "totalHis.Max")

}
2 changes: 1 addition & 1 deletion common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.13)
project(pinpoint VERSION 0.4.24 DESCRIPTION "pinpoint common library")
project(pinpoint VERSION 0.4.25 DESCRIPTION "pinpoint common library")

set(CMAKE_CXX_STANDARD 11)

Expand Down
2 changes: 1 addition & 1 deletion common/include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,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.4.24"
#define PINPOINT_C_AGENT_API_VERSION "0.4.25"

/**
* @brief change logs
Expand Down
8 changes: 7 additions & 1 deletion common/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@
```shell
$ cmake -DWITH_TEST_CASE=1 -DWITH_CODECOVERAGE=1 -DCMAKE_BUILD_TYPE=Debug ..
$ ./bin/TestCommon --gtest_filter=node.wakeTrace
```
```

## Changes

- 2023/11/23
- support FetchContent #561

23 changes: 8 additions & 15 deletions common/src/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,22 +182,15 @@ int pinpoint_wake_trace(NodeID traceId) {
}

int pinpoint_force_end_trace(NodeID id, int32_t timeout) {
try {
_span_timeout = timeout;
while (id != E_ROOT_NODE) {
id = pinpoint_end_trace(id);
if (id == E_INVALID_NODE)
break;
}
// back to normal
_span_timeout = global_agent_info.timeout_ms;
return 0;
} catch (const std::out_of_range&) {
pp_trace(" [%d] not found", id);
} catch (const std::exception& ex) {
pp_trace(" [%d] end trace failed. %s", id, ex.what());
_span_timeout = timeout;
while (id != E_ROOT_NODE) {
id = pinpoint_end_trace(id);
if (id == E_INVALID_NODE)
break;
}
return -1;
// back to normal
_span_timeout = global_agent_info.timeout_ms;
return 0;
}

int pinpoint_trace_is_root(NodeID _id) {
Expand Down
4 changes: 4 additions & 0 deletions common/test/test_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ TEST(common, start_end_trace) {

id = pinpoint_end_trace(id);
EXPECT_EQ(id, 0);
mark_current_trace_status(-1024, E_TRACE_BLOCK);
mark_current_trace_status(1024, E_TRACE_BLOCK);
catch_error(-1024, "sdfasfas", "fsafdsfasd", 234);
catch_error(0, "sdfasfas", "fsafdsfasd", 234);
}

TEST(common, context_check) {
Expand Down
Loading

0 comments on commit 1e49471

Please sign in to comment.