Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
润土的好友猹
SkyWalking
提交
61853516
S
SkyWalking
项目概览
润土的好友猹
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
61853516
编写于
2月 17, 2020
作者:
静夜思朝颜
提交者:
GitHub
2月 17, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix profile analyze missed data (#4378)
上级
ca6a5618
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
86 addition
and
19 deletion
+86
-19
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileAnalyzer.java
...king/oap/server/core/profile/analyze/ProfileAnalyzer.java
+4
-7
oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileAnalyzerTest.java
.../oap/server/core/profile/analyze/ProfileAnalyzerTest.java
+6
-5
oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackAnalyze.java
.../oap/server/core/profile/analyze/ProfileStackAnalyze.java
+49
-3
oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackData.java
...ing/oap/server/core/profile/analyze/ProfileStackData.java
+7
-4
oap-server/server-core/src/test/resources/thread-snapshot.yml
...server/server-core/src/test/resources/thread-snapshot.yml
+20
-0
未找到文件。
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileAnalyzer.java
浏览文件 @
61853516
...
...
@@ -51,7 +51,7 @@ public class ProfileAnalyzer {
private
final
int
analyzeSnapshotMaxSize
;
private
final
ModuleManager
moduleManager
;
pr
ivate
IProfileThreadSnapshotQueryDAO
profileThreadSnapshotQueryDAO
;
pr
otected
IProfileThreadSnapshotQueryDAO
profileThreadSnapshotQueryDAO
;
public
ProfileAnalyzer
(
ModuleManager
moduleManager
,
int
snapshotAnalyzeBatchSize
,
int
analyzeSnapshotMaxSize
)
{
this
.
moduleManager
=
moduleManager
;
...
...
@@ -91,7 +91,7 @@ public class ProfileAnalyzer {
return
analyzation
;
}
pr
ivate
SequenceSearch
getAllSequenceRange
(
String
segmentId
,
long
start
,
long
end
)
throws
IOException
{
pr
otected
SequenceSearch
getAllSequenceRange
(
String
segmentId
,
long
start
,
long
end
)
throws
IOException
{
// query min and max sequence
int
minSequence
=
getProfileThreadSnapshotQueryDAO
().
queryMinSequence
(
segmentId
,
start
,
end
);
int
maxSequence
=
getProfileThreadSnapshotQueryDAO
().
queryMaxSequence
(
segmentId
,
start
,
end
);
...
...
@@ -107,13 +107,10 @@ public class ProfileAnalyzer {
do
{
int
batchMax
=
Math
.
min
(
minSequence
+
threadSnapshotAnalyzeBatchSize
,
maxSequence
);
sequenceSearch
.
getRanges
().
add
(
new
SequenceRange
(
minSequence
,
batchMax
));
minSequence
=
batchMax
+
1
;
minSequence
=
batchMax
;
}
while
(
minSequence
<
maxSequence
);
// increase last range max sequence, need to include last sequence data
sequenceSearch
.
getRanges
().
getLast
().
increaseMaxSequence
();
return
sequenceSearch
;
}
...
...
@@ -135,7 +132,7 @@ public class ProfileAnalyzer {
return
new
ArrayList
<>(
stackTrees
.
values
());
}
pr
ivate
IProfileThreadSnapshotQueryDAO
getProfileThreadSnapshotQueryDAO
()
{
pr
otected
IProfileThreadSnapshotQueryDAO
getProfileThreadSnapshotQueryDAO
()
{
if
(
profileThreadSnapshotQueryDAO
==
null
)
{
profileThreadSnapshotQueryDAO
=
moduleManager
.
find
(
StorageModule
.
NAME
)
.
provider
()
...
...
oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/profile/ProfileAnalyzerTest.java
→
oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/profile/
analyze/
ProfileAnalyzerTest.java
浏览文件 @
61853516
...
...
@@ -16,23 +16,24 @@
*
*/
package
org.apache.skywalking.oap.server.core.profile
;
package
org.apache.skywalking.oap.server.core.profile
.analyze
;
import
org.apache.skywalking.oap.server.core.profile.analyze.ProfileStackAnalyze
;
import
org.apache.skywalking.oap.server.core.profile.analyze.ProfileStackAnalyzeHolder
;
import
org.junit.Test
;
import
org.yaml.snakeyaml.Yaml
;
import
java.io.IOException
;
import
java.io.InputStream
;
public
class
ProfileAnalyzerTest
{
public
static
final
int
MAX_ANALYZE_COUNT
=
10
;
@Test
public
void
testAnalyze
()
{
public
void
testAnalyze
()
throws
IOException
{
ProfileStackAnalyzeHolder
holder
=
loadYaml
(
"thread-snapshot.yml"
,
ProfileStackAnalyzeHolder
.
class
);
for
(
ProfileStackAnalyze
analyze
:
holder
.
getList
())
{
analyze
.
analyzeAndAssert
();
analyze
.
analyzeAndAssert
(
MAX_ANALYZE_COUNT
);
}
}
...
...
oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackAnalyze.java
浏览文件 @
61853516
...
...
@@ -18,9 +18,15 @@
package
org.apache.skywalking.oap.server.core.profile.analyze
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
lombok.Data
;
import
org.apache.skywalking.oap.server.core.profile.ProfileThreadSnapshotRecord
;
import
org.apache.skywalking.oap.server.core.query.entity.BasicTrace
;
import
org.apache.skywalking.oap.server.core.query.entity.ProfileStackTree
;
import
org.apache.skywalking.oap.server.core.storage.profile.IProfileThreadSnapshotQueryDAO
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
...
...
@@ -31,9 +37,10 @@ public class ProfileStackAnalyze {
private
ProfileStackData
data
;
private
List
<
ProfileStackElementMatcher
>
expected
;
public
void
analyzeAndAssert
()
{
List
<
ProfileStack
>
stacks
=
data
.
transform
();
List
<
ProfileStackTree
>
trees
=
new
ProfileAnalyzer
(
null
,
100
,
500
).
analyze
(
stacks
);
public
void
analyzeAndAssert
(
int
maxAnalyzeCount
)
throws
IOException
{
List
<
ProfileThreadSnapshotRecord
>
stacks
=
data
.
transform
();
List
<
ProfileStackTree
>
trees
=
buildAnalyzer
(
stacks
,
maxAnalyzeCount
).
analyze
(
null
,
0
,
0
).
getTrees
();
assertNotNull
(
trees
);
assertEquals
(
trees
.
size
(),
expected
.
size
());
...
...
@@ -42,4 +49,43 @@ public class ProfileStackAnalyze {
}
}
private
ProfileAnalyzer
buildAnalyzer
(
List
<
ProfileThreadSnapshotRecord
>
stacks
,
int
maxAnalyzeCount
)
throws
IOException
{
ProfileAnalyzer
analyzer
=
new
ProfileAnalyzer
(
null
,
2
,
maxAnalyzeCount
);
analyzer
.
profileThreadSnapshotQueryDAO
=
new
ThreadSnapshotDAO
(
stacks
);
return
analyzer
;
}
static
class
ThreadSnapshotDAO
implements
IProfileThreadSnapshotQueryDAO
{
private
final
List
<
ProfileThreadSnapshotRecord
>
stacks
;
public
ThreadSnapshotDAO
(
List
<
ProfileThreadSnapshotRecord
>
stacks
)
{
this
.
stacks
=
stacks
;
}
@Override
public
List
<
BasicTrace
>
queryProfiledSegments
(
String
taskId
)
throws
IOException
{
return
null
;
}
@Override
public
int
queryMinSequence
(
String
segmentId
,
long
start
,
long
end
)
throws
IOException
{
return
0
;
}
@Override
public
int
queryMaxSequence
(
String
segmentId
,
long
start
,
long
end
)
throws
IOException
{
return
stacks
.
size
();
}
@Override
public
List
<
ProfileThreadSnapshotRecord
>
queryRecords
(
String
segmentId
,
int
minSequence
,
int
maxSequence
)
throws
IOException
{
return
stacks
.
stream
()
.
filter
(
s
->
s
.
getSequence
()
>=
minSequence
)
.
filter
(
s
->
s
.
getSequence
()
<
maxSequence
)
.
collect
(
Collectors
.
toList
());
}
}
}
oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackData.java
浏览文件 @
61853516
...
...
@@ -20,6 +20,8 @@ package org.apache.skywalking.oap.server.core.profile.analyze;
import
com.google.common.base.Splitter
;
import
lombok.Data
;
import
org.apache.skywalking.apm.network.language.profile.ThreadStack
;
import
org.apache.skywalking.oap.server.core.profile.ProfileThreadSnapshotRecord
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -30,14 +32,15 @@ public class ProfileStackData {
private
int
limit
;
private
List
<
String
>
snapshots
;
public
List
<
Profile
Stack
>
transform
()
{
ArrayList
<
Profile
Stack
>
result
=
new
ArrayList
<>(
snapshots
.
size
());
public
List
<
Profile
ThreadSnapshotRecord
>
transform
()
{
ArrayList
<
Profile
ThreadSnapshotRecord
>
result
=
new
ArrayList
<>(
snapshots
.
size
());
for
(
int
i
=
0
;
i
<
snapshots
.
size
();
i
++)
{
Profile
Stack
stack
=
new
ProfileStack
();
Profile
ThreadSnapshotRecord
stack
=
new
ProfileThreadSnapshotRecord
();
stack
.
setSequence
(
i
);
stack
.
setDumpTime
(
i
*
limit
);
stack
.
setStack
(
Splitter
.
on
(
"-"
).
splitToList
(
snapshots
.
get
(
i
)));
ThreadStack
stackData
=
ThreadStack
.
newBuilder
().
addAllCodeSignatures
(
Splitter
.
on
(
"-"
).
splitToList
(
snapshots
.
get
(
i
))).
build
();
stack
.
setStackBinary
(
stackData
.
toByteArray
());
result
.
add
(
stack
);
}
...
...
oap-server/server-core/src/test/resources/thread-snapshot.yml
浏览文件 @
61853516
...
...
@@ -200,3 +200,23 @@ list:
-
code
:
E
count
:
1
duration
:
0:0
# case 7(only analyze first 10 snapshots):
-
data
:
limit
:
10
snapshots
:
-
A
-
A
-
A
-
A
-
A
-
A
-
A
-
A
-
A
-
A
-
A
expected
:
-
code
:
A
count
:
10
duration
:
90:90
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录