Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
9a1518a6
S
SkyWalking
项目概览
apache
/
SkyWalking
上一次同步 大约 1 年
通知
302
Star
21345
Fork
6091
代码
文件
提交
分支
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
9a1518a6
编写于
3月 17, 2019
作者:
X
Xin,Zhang
提交者:
GitHub
3月 17, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into qualified-spring-mvc-endpoints
上级
fe9f81bc
4962cbbb
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
308 addition
and
10 deletion
+308
-10
oap-server/generate-tool-grammar/src/main/antlr4/org/apache/skywalking/oal/tool/grammar/OALLexer.g4
...antlr4/org/apache/skywalking/oal/tool/grammar/OALLexer.g4
+6
-2
oap-server/generate-tool-grammar/src/main/antlr4/org/apache/skywalking/oal/tool/grammar/OALParser.g4
...ntlr4/org/apache/skywalking/oal/tool/grammar/OALParser.g4
+22
-2
oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/DeepAnalysis.java
...a/org/apache/skywalking/oal/tool/parser/DeepAnalysis.java
+20
-0
oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/OALListener.java
...va/org/apache/skywalking/oal/tool/parser/OALListener.java
+20
-0
oap-server/generate-tool/src/main/resources/code-templates/DispatcherTemplate.ftl
.../src/main/resources/code-templates/DispatcherTemplate.ftl
+6
-0
oap-server/generate-tool/src/test/java/org/apache/skywalking/oal/tool/output/FileGeneratorTest.java
.../apache/skywalking/oal/tool/output/FileGeneratorTest.java
+12
-6
oap-server/generate-tool/src/test/java/org/apache/skywalking/oal/tool/parser/ScriptParserTest.java
...g/apache/skywalking/oal/tool/parser/ScriptParserTest.java
+55
-0
oap-server/generate-tool/src/test/resources/expectedFiles/ServiceDispatcherExpected.java
...st/resources/expectedFiles/ServiceDispatcherExpected.java
+3
-0
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/GreaterEqualMatch.java
...core/analysis/indicator/expression/GreaterEqualMatch.java
+41
-0
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/GreaterMatch.java
...rver/core/analysis/indicator/expression/GreaterMatch.java
+41
-0
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/LessEqualMatch.java
...er/core/analysis/indicator/expression/LessEqualMatch.java
+41
-0
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/LessMatch.java
.../server/core/analysis/indicator/expression/LessMatch.java
+41
-0
未找到文件。
oap-server/generate-tool-grammar/src/main/antlr4/org/apache/skywalking/oal/tool/grammar/OALLexer.g4
浏览文件 @
9a1518a6
...
...
@@ -49,7 +49,7 @@ BOOL_LITERAL: 'true'
| 'false'
;
INT
_LITERAL : Digits+;
NUMBER
_LITERAL : Digits+;
CHAR_LITERAL: '\'' (~['\\\r\n] | EscapeSequence) '\'';
...
...
@@ -111,4 +111,8 @@ COMMA: ',';
SEMI: ';';
EQUAL: '=';
DUALEQUALS: '==';
ALL: '*';
\ No newline at end of file
ALL: '*';
GREATER: '>';
LESS: '<';
GREATER_EQUAL: '>=';
LESS_EQUAL: '<=';
\ No newline at end of file
oap-server/generate-tool-grammar/src/main/antlr4/org/apache/skywalking/oal/tool/grammar/OALParser.g4
浏览文件 @
9a1518a6
...
...
@@ -74,11 +74,11 @@ funcParamExpression
;
literalExpression
: BOOL_LITERAL |
INT
_LITERAL
: BOOL_LITERAL |
NUMBER
_LITERAL
;
expression
: booleanMatch | stringMatch
: booleanMatch | stringMatch
| greaterMatch | lessMatch | greaterEqualMatch | lessEqualMatch
;
booleanMatch
...
...
@@ -89,6 +89,22 @@ stringMatch
: conditionAttribute DUALEQUALS (stringConditionValue | enumConditionValue)
;
greaterMatch
: conditionAttribute GREATER numberConditionValue
;
lessMatch
: conditionAttribute LESS numberConditionValue
;
greaterEqualMatch
: conditionAttribute GREATER_EQUAL numberConditionValue
;
lessEqualMatch
: conditionAttribute LESS_EQUAL numberConditionValue
;
conditionAttribute
: IDENTIFIER
;
...
...
@@ -103,4 +119,8 @@ stringConditionValue
enumConditionValue
: IDENTIFIER DOT IDENTIFIER
;
numberConditionValue
: NUMBER_LITERAL
;
\ No newline at end of file
oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/DeepAnalysis.java
浏览文件 @
9a1518a6
...
...
@@ -51,6 +51,26 @@ public class DeepAnalysis {
filterExpression
.
setLeft
(
"source."
+
ClassMethodUtil
.
toGetMethod
(
expression
.
getAttribute
())
+
"()"
);
filterExpression
.
setRight
(
expression
.
getValue
());
result
.
addFilterExpressions
(
filterExpression
);
}
else
if
(
"greaterMatch"
.
equals
(
expression
.
getExpressionType
()))
{
filterExpression
.
setExpressionObject
(
"GreaterMatch"
);
filterExpression
.
setLeft
(
"source."
+
ClassMethodUtil
.
toGetMethod
(
expression
.
getAttribute
())
+
"()"
);
filterExpression
.
setRight
(
expression
.
getValue
());
result
.
addFilterExpressions
(
filterExpression
);
}
else
if
(
"lessMatch"
.
equals
(
expression
.
getExpressionType
()))
{
filterExpression
.
setExpressionObject
(
"LessMatch"
);
filterExpression
.
setLeft
(
"source."
+
ClassMethodUtil
.
toGetMethod
(
expression
.
getAttribute
())
+
"()"
);
filterExpression
.
setRight
(
expression
.
getValue
());
result
.
addFilterExpressions
(
filterExpression
);
}
else
if
(
"greaterEqualMatch"
.
equals
(
expression
.
getExpressionType
()))
{
filterExpression
.
setExpressionObject
(
"GreaterEqualMatch"
);
filterExpression
.
setLeft
(
"source."
+
ClassMethodUtil
.
toGetMethod
(
expression
.
getAttribute
())
+
"()"
);
filterExpression
.
setRight
(
expression
.
getValue
());
result
.
addFilterExpressions
(
filterExpression
);
}
else
if
(
"lessEqualMatch"
.
equals
(
expression
.
getExpressionType
()))
{
filterExpression
.
setExpressionObject
(
"LessEqualMatch"
);
filterExpression
.
setLeft
(
"source."
+
ClassMethodUtil
.
toGetMethod
(
expression
.
getAttribute
())
+
"()"
);
filterExpression
.
setRight
(
expression
.
getValue
());
result
.
addFilterExpressions
(
filterExpression
);
}
else
{
throw
new
IllegalArgumentException
(
"filter expression ["
+
expression
.
getExpressionType
()
+
"] not found"
);
}
...
...
oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/OALListener.java
浏览文件 @
9a1518a6
...
...
@@ -101,6 +101,22 @@ public class OALListener extends OALParserBaseListener {
conditionExpression
.
setExpressionType
(
"stringMatch"
);
}
@Override
public
void
enterGreaterMatch
(
OALParser
.
GreaterMatchContext
ctx
)
{
conditionExpression
.
setExpressionType
(
"greaterMatch"
);
}
@Override
public
void
enterGreaterEqualMatch
(
OALParser
.
GreaterEqualMatchContext
ctx
)
{
conditionExpression
.
setExpressionType
(
"greaterEqualMatch"
);
}
@Override
public
void
enterLessMatch
(
OALParser
.
LessMatchContext
ctx
)
{
conditionExpression
.
setExpressionType
(
"lessMatch"
);
}
@Override
public
void
enterLessEqualMatch
(
OALParser
.
LessEqualMatchContext
ctx
)
{
conditionExpression
.
setExpressionType
(
"lessEqualMatch"
);
}
@Override
public
void
enterBooleanConditionValue
(
OALParser
.
BooleanConditionValueContext
ctx
)
{
conditionExpression
.
setValue
(
ctx
.
getText
());
}
...
...
@@ -113,6 +129,10 @@ public class OALListener extends OALParserBaseListener {
conditionExpression
.
setValue
(
ctx
.
getText
());
}
@Override
public
void
enterNumberConditionValue
(
OALParser
.
NumberConditionValueContext
ctx
)
{
conditionExpression
.
setValue
(
ctx
.
getText
());
}
/////////////
// Expression end.
////////////
...
...
oap-server/generate-tool/src/main/resources/code-templates/DispatcherTemplate.ftl
浏览文件 @
9a1518a6
...
...
@@ -49,9 +49,15 @@ public class ${source}Dispatcher implements SourceDispatcher<${source}> {
<#if indicator.filterExpressions??>
<#list indicator.filterExpressions as filterExpression>
<#if filterExpression.expressionObject == "GreaterMatch" || filterExpression.expressionObject == "LessMatch" || filterExpression.expressionObject == "GreaterEqualMatch" || filterExpression.expressionObject == "LessEqualMatch">
if (!new ${filterExpression.expressionObject}().match(${filterExpression.left}, ${filterExpression.right})) {
return;
}
<#else>
if (!new ${filterExpression.expressionObject}().setLeft(${filterExpression.left}).setRight(${filterExpression.right}).match()) {
return;
}
</#if>
</#list>
</#if>
...
...
oap-server/generate-tool/src/test/java/org/apache/skywalking/oal/tool/output/FileGeneratorTest.java
浏览文件 @
9a1518a6
...
...
@@ -46,11 +46,17 @@ public class FileGeneratorTest {
result
.
setAggregationFunctionName
(
"avg"
);
result
.
setIndicatorClassName
(
"LongAvgIndicator"
);
FilterExpression
expression
=
new
FilterExpression
();
expression
.
setExpressionObject
(
"EqualMatch"
);
expression
.
setLeft
(
"source.getName()"
);
expression
.
setRight
(
"\"/service/prod/save\""
);
result
.
addFilterExpressions
(
expression
);
FilterExpression
equalExpression
=
new
FilterExpression
();
equalExpression
.
setExpressionObject
(
"EqualMatch"
);
equalExpression
.
setLeft
(
"source.getName()"
);
equalExpression
.
setRight
(
"\"/service/prod/save\""
);
result
.
addFilterExpressions
(
equalExpression
);
FilterExpression
greaterExpression
=
new
FilterExpression
();
greaterExpression
.
setExpressionObject
(
"GreaterMatch"
);
greaterExpression
.
setLeft
(
"source.getLatency()"
);
greaterExpression
.
setRight
(
"1000"
);
result
.
addFilterExpressions
(
greaterExpression
);
EntryMethod
method
=
new
EntryMethod
();
method
.
setMethodName
(
"combine"
);
...
...
@@ -96,7 +102,7 @@ public class FileGeneratorTest {
fileGenerator
.
generateDispatcher
(
result
,
writer
);
Assert
.
assertEquals
(
readExpectedFile
(
"ServiceDispatcherExpected.java"
),
writer
.
toString
());
//fileGenerator.generateServiceDispatcher(
new OutputStreamWriter(System.out));
// fileGenerator.generateDispatcher(result,
new OutputStreamWriter(System.out));
}
private
String
readExpectedFile
(
String
filename
)
throws
IOException
{
...
...
oap-server/generate-tool/src/test/java/org/apache/skywalking/oal/tool/parser/ScriptParserTest.java
浏览文件 @
9a1518a6
...
...
@@ -112,4 +112,59 @@ public class ScriptParserTest {
Assert
.
assertEquals
(
"\"/product/abc\""
,
stringMatchExp
.
getValue
());
Assert
.
assertEquals
(
"stringMatch"
,
stringMatchExp
.
getExpressionType
());
}
@Test
public
void
testParse4
()
throws
IOException
{
ScriptParser
parser
=
ScriptParser
.
createFromScriptText
(
"service_response_s1_summary = from(Service.latency).filter(latency > 1000).sum();"
+
"\n"
+
"service_response_s2_summary = from(Service.latency).filter(latency < 2000).sum();"
+
"\n"
+
"service_response_s3_summary = from(Service.latency).filter(latency >= 3000).sum();"
+
"\n"
+
"service_response_s4_summary = from(Service.latency).filter(latency <= 4000).sum();"
);
List
<
AnalysisResult
>
results
=
parser
.
parse
();
AnalysisResult
responseSummary
=
results
.
get
(
0
);
Assert
.
assertEquals
(
"ServiceResponseS1Summary"
,
responseSummary
.
getMetricName
());
Assert
.
assertEquals
(
"Service"
,
responseSummary
.
getSourceName
());
Assert
.
assertEquals
(
"latency"
,
responseSummary
.
getSourceAttribute
());
Assert
.
assertEquals
(
"sum"
,
responseSummary
.
getAggregationFunctionName
());
List
<
ConditionExpression
>
expressions
=
responseSummary
.
getFilterExpressionsParserResult
();
Assert
.
assertEquals
(
1
,
expressions
.
size
());
ConditionExpression
booleanMatchExp
=
expressions
.
get
(
0
);
Assert
.
assertEquals
(
"latency"
,
booleanMatchExp
.
getAttribute
());
Assert
.
assertEquals
(
"1000"
,
booleanMatchExp
.
getValue
());
Assert
.
assertEquals
(
"greaterMatch"
,
booleanMatchExp
.
getExpressionType
());
responseSummary
=
results
.
get
(
1
);
expressions
=
responseSummary
.
getFilterExpressionsParserResult
();
Assert
.
assertEquals
(
1
,
expressions
.
size
());
booleanMatchExp
=
expressions
.
get
(
0
);
Assert
.
assertEquals
(
"latency"
,
booleanMatchExp
.
getAttribute
());
Assert
.
assertEquals
(
"2000"
,
booleanMatchExp
.
getValue
());
Assert
.
assertEquals
(
"lessMatch"
,
booleanMatchExp
.
getExpressionType
());
responseSummary
=
results
.
get
(
2
);
expressions
=
responseSummary
.
getFilterExpressionsParserResult
();
Assert
.
assertEquals
(
1
,
expressions
.
size
());
booleanMatchExp
=
expressions
.
get
(
0
);
Assert
.
assertEquals
(
"latency"
,
booleanMatchExp
.
getAttribute
());
Assert
.
assertEquals
(
"3000"
,
booleanMatchExp
.
getValue
());
Assert
.
assertEquals
(
"greaterEqualMatch"
,
booleanMatchExp
.
getExpressionType
());
responseSummary
=
results
.
get
(
3
);
expressions
=
responseSummary
.
getFilterExpressionsParserResult
();
Assert
.
assertEquals
(
1
,
expressions
.
size
());
booleanMatchExp
=
expressions
.
get
(
0
);
Assert
.
assertEquals
(
"latency"
,
booleanMatchExp
.
getAttribute
());
Assert
.
assertEquals
(
"4000"
,
booleanMatchExp
.
getValue
());
Assert
.
assertEquals
(
"lessEqualMatch"
,
booleanMatchExp
.
getExpressionType
());
}
}
oap-server/generate-tool/src/test/resources/expectedFiles/ServiceDispatcherExpected.java
浏览文件 @
9a1518a6
...
...
@@ -40,6 +40,9 @@ public class ServiceDispatcher implements SourceDispatcher<Service> {
if
(!
new
EqualMatch
().
setLeft
(
source
.
getName
()).
setRight
(
"/service/prod/save"
).
match
())
{
return
;
}
if
(!
new
GreaterMatch
().
match
(
source
.
getLatency
(),
1000
))
{
return
;
}
indicator
.
setTimeBucket
(
source
.
getTimeBucket
());
indicator
.
setEntityId
(
source
.
getEntityId
());
...
...
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/GreaterEqualMatch.java
0 → 100644
浏览文件 @
9a1518a6
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.oap.server.core.analysis.indicator.expression
;
/**
* @author peng-yongsheng
*/
public
class
GreaterEqualMatch
{
public
boolean
match
(
Integer
left
,
Integer
right
)
{
return
left
>=
right
;
}
public
boolean
match
(
Long
left
,
Long
right
)
{
return
left
>=
right
;
}
public
boolean
match
(
Float
left
,
Float
right
)
{
return
left
>=
right
;
}
public
boolean
match
(
Double
left
,
Double
right
)
{
return
left
>=
right
;
}
}
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/GreaterMatch.java
0 → 100644
浏览文件 @
9a1518a6
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.oap.server.core.analysis.indicator.expression
;
/**
* @author peng-yongsheng
*/
public
class
GreaterMatch
{
public
boolean
match
(
Integer
left
,
Integer
right
)
{
return
left
>
right
;
}
public
boolean
match
(
Long
left
,
Long
right
)
{
return
left
>
right
;
}
public
boolean
match
(
Float
left
,
Float
right
)
{
return
left
>
right
;
}
public
boolean
match
(
Double
left
,
Double
right
)
{
return
left
>
right
;
}
}
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/LessEqualMatch.java
0 → 100644
浏览文件 @
9a1518a6
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.oap.server.core.analysis.indicator.expression
;
/**
* @author peng-yongsheng
*/
public
class
LessEqualMatch
{
public
boolean
match
(
Integer
left
,
Integer
right
)
{
return
left
<=
right
;
}
public
boolean
match
(
Long
left
,
Long
right
)
{
return
left
<=
right
;
}
public
boolean
match
(
Float
left
,
Float
right
)
{
return
left
<=
right
;
}
public
boolean
match
(
Double
left
,
Double
right
)
{
return
left
<=
right
;
}
}
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/LessMatch.java
0 → 100644
浏览文件 @
9a1518a6
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.oap.server.core.analysis.indicator.expression
;
/**
* @author peng-yongsheng
*/
public
class
LessMatch
{
public
boolean
match
(
Integer
left
,
Integer
right
)
{
return
left
<
right
;
}
public
boolean
match
(
Long
left
,
Long
right
)
{
return
left
<
right
;
}
public
boolean
match
(
Float
left
,
Float
right
)
{
return
left
<
right
;
}
public
boolean
match
(
Double
left
,
Double
right
)
{
return
left
<
right
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录