Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
月轩居士
SkyWalking
提交
a498a91f
S
SkyWalking
项目概览
月轩居士
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
4
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,发现更多精彩内容 >>
未验证
提交
a498a91f
编写于
3月 01, 2018
作者:
wu-sheng
提交者:
GitHub
3月 01, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #854 from peng-yongsheng/feature/TraceQuery
"queryBasicTraces","queryTrace"
上级
ce3bff89
b7f1f4c5
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
60 addition
and
30 deletion
+60
-30
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/ISegmentDurationUIDAO.java
...g/apm/collector/storage/dao/ui/ISegmentDurationUIDAO.java
+2
-2
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Pagination.java
...kywalking/apm/collector/storage/ui/common/Pagination.java
+9
-9
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentDurationEsUIDAO.java
...m/collector/storage/es/dao/ui/SegmentDurationEsUIDAO.java
+9
-5
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/SegmentDurationH2UIDAO.java
...m/collector/storage/h2/dao/ui/SegmentDurationH2UIDAO.java
+6
-6
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/TraceQuery.java
.../apache/skywalking/apm/collector/ui/query/TraceQuery.java
+16
-4
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SegmentTopService.java
...kywalking/apm/collector/ui/service/SegmentTopService.java
+18
-4
未找到文件。
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/ISegmentDurationUIDAO.java
浏览文件 @
a498a91f
...
...
@@ -25,6 +25,6 @@ import org.apache.skywalking.apm.collector.storage.ui.trace.TraceBrief;
* @author peng-yongsheng
*/
public
interface
ISegmentDurationUIDAO
extends
DAO
{
TraceBrief
loadTop
(
long
start
Time
,
long
endTime
,
long
minDuration
,
long
maxDuration
,
String
operationName
,
int
applicationId
,
String
traceId
,
int
limit
,
int
from
);
TraceBrief
loadTop
(
long
start
SecondTimeBucket
,
long
endSecondTimeBucket
,
long
minDuration
,
long
maxDuration
,
String
operationName
,
int
applicationId
,
int
limit
,
int
from
,
String
...
segmentIds
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Pagination.java
浏览文件 @
a498a91f
...
...
@@ -22,31 +22,31 @@ package org.apache.skywalking.apm.collector.storage.ui.common;
* @author peng-yongsheng
*/
public
class
Pagination
{
private
Integer
pageNum
;
private
Integer
pageSize
;
private
B
oolean
needTotal
;
private
int
pageNum
;
private
int
pageSize
;
private
b
oolean
needTotal
;
public
Integer
getPageNum
()
{
public
int
getPageNum
()
{
return
pageNum
;
}
public
void
setPageNum
(
Integer
pageNum
)
{
public
void
setPageNum
(
int
pageNum
)
{
this
.
pageNum
=
pageNum
;
}
public
Integer
getPageSize
()
{
public
int
getPageSize
()
{
return
pageSize
;
}
public
void
setPageSize
(
Integer
pageSize
)
{
public
void
setPageSize
(
int
pageSize
)
{
this
.
pageSize
=
pageSize
;
}
public
Boolean
get
NeedTotal
()
{
public
boolean
is
NeedTotal
()
{
return
needTotal
;
}
public
void
setNeedTotal
(
B
oolean
needTotal
)
{
public
void
setNeedTotal
(
b
oolean
needTotal
)
{
this
.
needTotal
=
needTotal
;
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentDurationEsUIDAO.java
浏览文件 @
a498a91f
...
...
@@ -21,6 +21,7 @@ package org.apache.skywalking.apm.collector.storage.es.dao.ui;
import
java.util.List
;
import
org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient
;
import
org.apache.skywalking.apm.collector.core.util.BooleanUtils
;
import
org.apache.skywalking.apm.collector.core.util.CollectionUtils
;
import
org.apache.skywalking.apm.collector.core.util.StringUtils
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO
;
import
org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
...
...
@@ -46,8 +47,8 @@ public class SegmentDurationEsUIDAO extends EsDAO implements ISegmentDurationUID
}
@Override
public
TraceBrief
loadTop
(
long
start
Time
,
long
endTime
,
long
minDuration
,
long
maxDuration
,
String
operationName
,
int
applicationId
,
String
traceId
,
int
limit
,
int
from
)
{
public
TraceBrief
loadTop
(
long
start
SecondTimeBucket
,
long
endSecondTimeBucket
,
long
minDuration
,
long
maxDuration
,
String
operationName
,
int
applicationId
,
int
limit
,
int
from
,
String
...
segmentIds
)
{
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
SegmentDurationTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
SegmentDurationTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
...
...
@@ -55,7 +56,10 @@ public class SegmentDurationEsUIDAO extends EsDAO implements ISegmentDurationUID
searchRequestBuilder
.
setQuery
(
boolQueryBuilder
);
List
<
QueryBuilder
>
mustQueryList
=
boolQueryBuilder
.
must
();
mustQueryList
.
add
(
QueryBuilders
.
rangeQuery
(
SegmentDurationTable
.
COLUMN_TIME_BUCKET
).
gte
(
startTime
).
lte
(
endTime
));
if
(
startSecondTimeBucket
!=
0
&&
endSecondTimeBucket
!=
0
)
{
mustQueryList
.
add
(
QueryBuilders
.
rangeQuery
(
SegmentDurationTable
.
COLUMN_TIME_BUCKET
).
gte
(
startSecondTimeBucket
).
lte
(
endSecondTimeBucket
));
}
if
(
minDuration
!=
0
||
maxDuration
!=
0
)
{
RangeQueryBuilder
rangeQueryBuilder
=
QueryBuilders
.
rangeQuery
(
SegmentDurationTable
.
COLUMN_DURATION
);
if
(
minDuration
!=
0
)
{
...
...
@@ -69,8 +73,8 @@ public class SegmentDurationEsUIDAO extends EsDAO implements ISegmentDurationUID
if
(
StringUtils
.
isNotEmpty
(
operationName
))
{
mustQueryList
.
add
(
QueryBuilders
.
matchQuery
(
SegmentDurationTable
.
COLUMN_SERVICE_NAME
,
operationName
));
}
if
(
StringUtils
.
isNotEmpty
(
traceId
))
{
boolQueryBuilder
.
must
().
add
(
QueryBuilders
.
term
Query
(
SegmentDurationTable
.
COLUMN_SEGMENT_ID
,
traceId
));
if
(
CollectionUtils
.
isNotEmpty
(
segmentIds
))
{
boolQueryBuilder
.
must
().
add
(
QueryBuilders
.
term
sQuery
(
SegmentDurationTable
.
COLUMN_SEGMENT_ID
,
segmentIds
));
}
if
(
applicationId
!=
0
)
{
boolQueryBuilder
.
must
().
add
(
QueryBuilders
.
termQuery
(
SegmentDurationTable
.
COLUMN_APPLICATION_ID
,
applicationId
));
...
...
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/SegmentDurationH2UIDAO.java
浏览文件 @
a498a91f
...
...
@@ -47,16 +47,16 @@ public class SegmentDurationH2UIDAO extends H2DAO implements ISegmentDurationUID
}
@Override
public
TraceBrief
loadTop
(
long
start
Time
,
long
endTime
,
long
minDuration
,
long
maxDuration
,
String
operationName
,
int
applicationId
,
String
traceId
,
int
limit
,
int
from
)
{
public
TraceBrief
loadTop
(
long
start
SecondTimeBucket
,
long
endSecondTimeBucket
,
long
minDuration
,
long
maxDuration
,
String
operationName
,
int
applicationId
,
int
limit
,
int
from
,
String
...
segmentIds
)
{
H2Client
client
=
getClient
();
String
sql
=
"select * from {0} where {1} >= ? and {1} <= ?"
;
List
<
Object
>
params
=
new
ArrayList
<>();
List
<
Object
>
columns
=
new
ArrayList
<>();
columns
.
add
(
SegmentDurationTable
.
TABLE
);
columns
.
add
(
SegmentDurationTable
.
COLUMN_TIME_BUCKET
);
params
.
add
(
start
Time
);
params
.
add
(
end
Time
);
params
.
add
(
start
SecondTimeBucket
);
params
.
add
(
end
SecondTimeBucket
);
int
paramIndex
=
1
;
if
(
minDuration
!=
-
1
||
maxDuration
!=
-
1
)
{
if
(
minDuration
!=
-
1
)
{
...
...
@@ -78,10 +78,10 @@ public class SegmentDurationH2UIDAO extends H2DAO implements ISegmentDurationUID
params
.
add
(
operationName
);
columns
.
add
(
SegmentDurationTable
.
COLUMN_SERVICE_NAME
);
}
if
(
StringUtils
.
isNotEmpty
(
traceId
))
{
if
(
StringUtils
.
isNotEmpty
(
segmentIds
))
{
paramIndex
++;
sql
=
sql
+
" and {"
+
paramIndex
+
"} = ?"
;
params
.
add
(
traceId
);
params
.
add
(
segmentIds
);
columns
.
add
(
SegmentDurationTable
.
COLUMN_TRACE_ID
);
}
if
(
applicationId
!=
0
)
{
...
...
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/TraceQuery.java
浏览文件 @
a498a91f
...
...
@@ -19,8 +19,11 @@
package
org.apache.skywalking.apm.collector.ui.query
;
import
java.text.ParseException
;
import
org.apache.skywalking.apm.collector.core.UnexpectedException
;
import
org.apache.skywalking.apm.collector.core.module.ModuleManager
;
import
org.apache.skywalking.apm.collector.core.util.Const
;
import
org.apache.skywalking.apm.collector.core.util.ObjectUtils
;
import
org.apache.skywalking.apm.collector.core.util.StringUtils
;
import
org.apache.skywalking.apm.collector.storage.ui.trace.Trace
;
import
org.apache.skywalking.apm.collector.storage.ui.trace.TraceBrief
;
import
org.apache.skywalking.apm.collector.storage.ui.trace.TraceQueryCondition
;
...
...
@@ -57,18 +60,27 @@ public class TraceQuery implements Query {
}
public
TraceBrief
queryBasicTraces
(
TraceQueryCondition
condition
)
throws
ParseException
{
long
start
=
DurationUtils
.
INSTANCE
.
durationToSecondTimeBucket
(
condition
.
getQueryDuration
().
getStep
(),
condition
.
getQueryDuration
().
getStart
());
long
end
=
DurationUtils
.
INSTANCE
.
durationToSecondTimeBucket
(
condition
.
getQueryDuration
().
getStep
(),
condition
.
getQueryDuration
().
getEnd
());
long
startSecondTimeBucket
=
0
;
long
endSecondTimeBucket
=
0
;
String
traceId
=
Const
.
EMPTY_STRING
;
if
(
ObjectUtils
.
isNotEmpty
(
condition
.
getQueryDuration
()))
{
startSecondTimeBucket
=
DurationUtils
.
INSTANCE
.
durationToSecondTimeBucket
(
condition
.
getQueryDuration
().
getStep
(),
condition
.
getQueryDuration
().
getStart
());
endSecondTimeBucket
=
DurationUtils
.
INSTANCE
.
durationToSecondTimeBucket
(
condition
.
getQueryDuration
().
getStep
(),
condition
.
getQueryDuration
().
getEnd
());
}
else
if
(
StringUtils
.
isNotEmpty
(
condition
.
getTraceId
()))
{
traceId
=
condition
.
getTraceId
();
}
else
{
throw
new
UnexpectedException
(
"The condition must contains either queryDuration or traceId."
);
}
long
minDuration
=
condition
.
getMinTraceDuration
();
long
maxDuration
=
condition
.
getMaxTraceDuration
();
String
operationName
=
condition
.
getOperationName
();
String
traceId
=
condition
.
getTraceId
();
int
applicationId
=
condition
.
getApplicationId
();
int
limit
=
condition
.
getPaging
().
getPageSize
();
int
from
=
condition
.
getPaging
().
getPageSize
()
*
condition
.
getPaging
().
getPageNum
();
return
getSegmentTopService
().
loadTop
(
start
,
end
,
minDuration
,
maxDuration
,
operationName
,
traceId
,
applicationId
,
limit
,
from
);
return
getSegmentTopService
().
loadTop
(
start
SecondTimeBucket
,
endSecondTimeBucket
,
minDuration
,
maxDuration
,
operationName
,
traceId
,
applicationId
,
limit
,
from
);
}
public
Trace
queryTrace
(
String
traceId
)
{
...
...
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SegmentTopService.java
浏览文件 @
a498a91f
...
...
@@ -18,8 +18,11 @@
package
org.apache.skywalking.apm.collector.ui.service
;
import
java.util.List
;
import
org.apache.skywalking.apm.collector.core.module.ModuleManager
;
import
org.apache.skywalking.apm.collector.core.util.StringUtils
;
import
org.apache.skywalking.apm.collector.storage.StorageModule
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IGlobalTraceUIDAO
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO
;
import
org.apache.skywalking.apm.collector.storage.ui.trace.TraceBrief
;
import
org.slf4j.Logger
;
...
...
@@ -33,15 +36,26 @@ public class SegmentTopService {
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SegmentTopService
.
class
);
private
final
ISegmentDurationUIDAO
segmentDurationUIDAO
;
private
final
IGlobalTraceUIDAO
globalTraceUIDAO
;
public
SegmentTopService
(
ModuleManager
moduleManager
)
{
this
.
segmentDurationUIDAO
=
moduleManager
.
find
(
StorageModule
.
NAME
).
getService
(
ISegmentDurationUIDAO
.
class
);
this
.
globalTraceUIDAO
=
moduleManager
.
find
(
StorageModule
.
NAME
).
getService
(
IGlobalTraceUIDAO
.
class
);
}
public
TraceBrief
loadTop
(
long
startTime
,
long
endTime
,
long
minDuration
,
long
maxDuration
,
String
operationName
,
public
TraceBrief
loadTop
(
long
startSecondTimeBucket
,
long
endSecondTimeBucket
,
long
minDuration
,
long
maxDuration
,
String
operationName
,
String
traceId
,
int
applicationId
,
int
limit
,
int
from
)
{
logger
.
debug
(
"startTime: {}, endTime: {}, minDuration: {}, maxDuration: {}, operationName: {}, traceId: {}, applicationId: {}, limit: {}, from: {}"
,
startTime
,
endTime
,
minDuration
,
maxDuration
,
operationName
,
traceId
,
applicationId
,
limit
,
from
);
return
segmentDurationUIDAO
.
loadTop
(
startTime
,
endTime
,
minDuration
,
maxDuration
,
operationName
,
applicationId
,
traceId
,
limit
,
from
);
logger
.
debug
(
"startSecondTimeBucket: {}, endSecondTimeBucket: {}, minDuration: {}, "
+
"maxDuration: {}, operationName: {}, traceId: {}, applicationId: {}, limit: {}, from: {}"
,
startSecondTimeBucket
,
endSecondTimeBucket
,
minDuration
,
maxDuration
,
operationName
,
traceId
,
applicationId
,
limit
,
from
);
if
(
StringUtils
.
isNotEmpty
(
traceId
))
{
List
<
String
>
segmentIds
=
globalTraceUIDAO
.
getSegmentIds
(
traceId
);
return
segmentDurationUIDAO
.
loadTop
(
startSecondTimeBucket
,
endSecondTimeBucket
,
minDuration
,
maxDuration
,
operationName
,
applicationId
,
limit
,
from
,
segmentIds
.
toArray
(
new
String
[
0
]));
}
else
{
return
segmentDurationUIDAO
.
loadTop
(
startSecondTimeBucket
,
endSecondTimeBucket
,
minDuration
,
maxDuration
,
operationName
,
applicationId
,
limit
,
from
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录