You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2020/03/11 06:39:47 UTC
[skywalking] branch master updated: fix overlapping time ranges
profile analyze error (#4487)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new 5ea0133 fix overlapping time ranges profile analyze error (#4487)
5ea0133 is described below
commit 5ea0133a62a69161835c7201b564311388728be4
Author: mrproliu <74...@qq.com>
AuthorDate: Wed Mar 11 14:39:40 2020 +0800
fix overlapping time ranges profile analyze error (#4487)
Co-authored-by: Mrproliu <mr...@lagou.com>
---
.../server/core/profile/analyze/ProfileAnalyzer.java | 2 +-
.../oap/server/core/profile/analyze/ProfileStack.java | 15 +++++++++++++++
.../server-core/src/test/resources/thread-snapshot.yml | 17 +++++++++++++++++
3 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileAnalyzer.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileAnalyzer.java
index 10f198d..d008e49 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileAnalyzer.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileAnalyzer.java
@@ -85,7 +85,7 @@ public class ProfileAnalyzer {
LOGGER.warn(e.getMessage(), e);
return Collections.<ProfileThreadSnapshotRecord>emptyList();
}
- }).flatMap(Collection::stream).map(ProfileStack::deserialize).collect(Collectors.toList());
+ }).flatMap(Collection::stream).map(ProfileStack::deserialize).distinct().collect(Collectors.toList());
// analyze
analyzation.setTrees(analyze(stacks));
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStack.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStack.java
index de10e5c..3af4204 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStack.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStack.java
@@ -21,6 +21,8 @@ package org.apache.skywalking.oap.server.core.profile.analyze;
import com.google.common.primitives.Ints;
import com.google.protobuf.InvalidProtocolBufferException;
import java.util.List;
+import java.util.Objects;
+
import lombok.Data;
import org.apache.skywalking.apm.network.language.profile.ThreadStack;
import org.apache.skywalking.oap.server.core.profile.ProfileThreadSnapshotRecord;
@@ -56,4 +58,17 @@ public class ProfileStack implements Comparable<ProfileStack> {
public int compareTo(ProfileStack o) {
return Ints.compare(sequence, o.sequence);
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ProfileStack that = (ProfileStack) o;
+ return sequence == that.sequence;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(sequence);
+ }
}
diff --git a/oap-server/server-core/src/test/resources/thread-snapshot.yml b/oap-server/server-core/src/test/resources/thread-snapshot.yml
index d5f6130..6ebc097 100644
--- a/oap-server/server-core/src/test/resources/thread-snapshot.yml
+++ b/oap-server/server-core/src/test/resources/thread-snapshot.yml
@@ -244,3 +244,20 @@ list:
- code: A
count: 5
duration: 30:30
+
+ # case 9(multiple time ranges with overlapping time)
+ - data:
+ limit: 10
+ timeRanges: 0-2,1-3,5-6
+ snapshots:
+ - A
+ - A
+ - A
+ - A
+ - B
+ - A
+ - A
+ expected:
+ - code: A
+ count: 6
+ duration: 40:40