fix overlapping time ranges profile analyze error (#4487)

Co-authored-by: Mrproliu <mrproliu@lagou.com>
This commit is contained in:
mrproliu 2020-03-11 14:39:40 +08:00 committed by GitHub
parent ced5cb2828
commit 5ea0133a62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 1 deletions

View File

@ -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));

View File

@ -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);
}
}

View File

@ -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