From 9d1ad53d55cc474a5b5568c3c7d53809d8e395cb Mon Sep 17 00:00:00 2001 From: yaofighting Date: Tue, 22 Nov 2022 16:41:20 +0800 Subject: [PATCH 1/3] Fix the bug of incomplete records when threads arrive at the cpu analyzer for the first time Signed-off-by: yaofighting --- CHANGELOG.md | 3 +++ .../analyzer/cpuanalyzer/cpu_analyzer.go | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe5012b4b..763b7d52e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ ### New features - Add a new feature: Trace Profiling. See more details about it on our [website](http://kindling.harmonycloud.cn). ([#335](https://github.com/CloudDectective-Harmonycloud/kindling/pull/335)) +### Bug fixes +- Fix the bug of incomplete records when threads arrive at the cpu analyzer for the first time + ### Enhancements - Add request and response payload of `Redis` protocol message to `Span` data. ([#325](https://github.com/CloudDectective-Harmonycloud/kindling/pull/325)) diff --git a/collector/pkg/component/analyzer/cpuanalyzer/cpu_analyzer.go b/collector/pkg/component/analyzer/cpuanalyzer/cpu_analyzer.go index 64e3a4ee7..4a780b436 100644 --- a/collector/pkg/component/analyzer/cpuanalyzer/cpu_analyzer.go +++ b/collector/pkg/component/analyzer/cpuanalyzer/cpu_analyzer.go @@ -2,14 +2,15 @@ package cpuanalyzer import ( "fmt" + "strconv" + "sync" + "github.com/Kindling-project/kindling/collector/pkg/component" "github.com/Kindling-project/kindling/collector/pkg/component/analyzer" "github.com/Kindling-project/kindling/collector/pkg/component/consumer" "github.com/Kindling-project/kindling/collector/pkg/model" "github.com/Kindling-project/kindling/collector/pkg/model/constnames" "go.uber.org/zap/zapcore" - "strconv" - "sync" ) const ( @@ -221,9 +222,16 @@ func (ca *CpuAnalyzer) PutEventToSegments(pid uint32, tid uint32, threadName str (newTimeSegments.BaseTime+uint64(i+1))*nanoToSeconds) newTimeSegments.Segments.UpdateByIndex(i, segment) } - val := newTimeSegments.Segments.GetByIndex(0) - segment := val.(*Segment) - segment.putTimedEvent(event) + + endOffset := int(event.EndTimestamp()/nanoToSeconds - newTimeSegments.BaseTime) + + for i := 0; i <= endOffset && i < maxSegmentSize; i++ { + val := newTimeSegments.Segments.GetByIndex(i) + segment := val.(*Segment) + segment.putTimedEvent(event) + segment.IsSend = 0 + } + tidCpuEvents[tid] = newTimeSegments } } From 9d5ad1e065b3af6fac980d2915ce4e0e4ef91bf7 Mon Sep 17 00:00:00 2001 From: yaofighting Date: Wed, 23 Nov 2022 10:06:36 +0800 Subject: [PATCH 2/3] update the CHANGELOG.md Signed-off-by: yaofighting --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 763b7d52e..ee7b31065 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,13 +7,13 @@ ### New features - Add a new tool: A debug tool for Trace Profiling is provided for developers to troubleshoot problems.([#363](https://github.com/CloudDectective-Harmonycloud/kindling/pull/363)) +### Bug fixes +- Fix the bug of incomplete records when threads arrive at the cpu analyzer for the first time + ## v0.5.0 - 2022-11-02 ### New features - Add a new feature: Trace Profiling. See more details about it on our [website](http://kindling.harmonycloud.cn). ([#335](https://github.com/CloudDectective-Harmonycloud/kindling/pull/335)) -### Bug fixes -- Fix the bug of incomplete records when threads arrive at the cpu analyzer for the first time - ### Enhancements - Add request and response payload of `Redis` protocol message to `Span` data. ([#325](https://github.com/CloudDectective-Harmonycloud/kindling/pull/325)) From ff9d7f8cc0c7eb0c5b1f7f72cb8fca26f8d9e041 Mon Sep 17 00:00:00 2001 From: yaofighting Date: Wed, 23 Nov 2022 10:15:05 +0800 Subject: [PATCH 3/3] update the CHANGELOG.md(add PR info) Signed-off-by: yaofighting --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee7b31065..1bd3b7fab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ - Add a new tool: A debug tool for Trace Profiling is provided for developers to troubleshoot problems.([#363](https://github.com/CloudDectective-Harmonycloud/kindling/pull/363)) ### Bug fixes -- Fix the bug of incomplete records when threads arrive at the cpu analyzer for the first time +- Fix the bug of incomplete records when threads arrive at the cpu analyzer for the first time. ([#364](https://github.com/CloudDectective-Harmonycloud/kindling/pull/364)) ## v0.5.0 - 2022-11-02 ### New features