Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
a3317a82
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 搜索 >>
未验证
提交
a3317a82
编写于
9月 02, 2021
作者:
Y
YczYanchengzhe
提交者:
GitHub
9月 02, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support for filter filtering of int type values (#7636)
上级
7d428ecc
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
183 addition
and
26 deletion
+183
-26
CHANGES.md
CHANGES.md
+1
-0
oap-server/oal-grammar/src/main/antlr4/org/apache/skywalking/oal/rt/grammar/OALParser.g4
.../antlr4/org/apache/skywalking/oal/rt/grammar/OALParser.g4
+5
-1
oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/OALListener.java
...java/org/apache/skywalking/oal/rt/parser/OALListener.java
+5
-0
oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/parser/DeepAnalysisTest.java
...org/apache/skywalking/oal/rt/parser/DeepAnalysisTest.java
+3
-3
oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/parser/ScriptParserTest.java
...org/apache/skywalking/oal/rt/parser/ScriptParserTest.java
+18
-0
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/NumberMatch.java
.../server/core/analysis/metrics/expression/NumberMatch.java
+33
-0
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/StringMatch.java
.../server/core/analysis/metrics/expression/StringMatch.java
+1
-1
oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/PercentMetricsTest.java
.../oap/server/core/analysis/metrics/PercentMetricsTest.java
+13
-13
oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/NumberMatchTest.java
...ver/core/analysis/metrics/expression/NumberMatchTest.java
+96
-0
oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/StringMatchTest.java
...ver/core/analysis/metrics/expression/StringMatchTest.java
+8
-8
未找到文件。
CHANGES.md
浏览文件 @
a3317a82
...
...
@@ -50,6 +50,7 @@ Release Notes.
*
Fix
`LoggingConfigWatcher`
return
`watch.value`
would not consistent with the real configuration content.
*
Fix
`ZookeeperConfigWatcherRegister.readConfig()`
could cause
`NPE`
when
`data.getData()`
is null.
*
Support nacos grouped dynamic configurations.
*
Support for filter function filtering of int type values.
#### UI
...
...
oap-server/oal-grammar/src/main/antlr4/org/apache/skywalking/oal/rt/grammar/OALParser.g4
浏览文件 @
a3317a82
...
...
@@ -93,7 +93,7 @@ literalExpression
;
expression
: booleanMatch | stringMatch | greaterMatch | lessMatch | greaterEqualMatch | lessEqualMatch | notEqualMatch | booleanNotEqualMatch | likeMatch | inMatch | containMatch | notContainMatch
: booleanMatch |
numberMatch |
stringMatch | greaterMatch | lessMatch | greaterEqualMatch | lessEqualMatch | notEqualMatch | booleanNotEqualMatch | likeMatch | inMatch | containMatch | notContainMatch
;
containMatch
...
...
@@ -108,6 +108,10 @@ booleanMatch
: conditionAttributeStmt DUALEQUALS booleanConditionValue
;
numberMatch
: conditionAttributeStmt DUALEQUALS numberConditionValue
;
stringMatch
: conditionAttributeStmt DUALEQUALS (stringConditionValue | enumConditionValue)
;
...
...
oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/OALListener.java
浏览文件 @
a3317a82
...
...
@@ -114,6 +114,11 @@ public class OALListener extends OALParserBaseListener {
conditionExpression
.
setExpressionType
(
"booleanMatch"
);
}
@Override
public
void
enterNumberMatch
(
OALParser
.
NumberMatchContext
ctx
)
{
conditionExpression
.
setExpressionType
(
"numberMatch"
);
}
@Override
public
void
enterStringMatch
(
OALParser
.
StringMatchContext
ctx
)
{
conditionExpression
.
setExpressionType
(
"stringMatch"
);
...
...
oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/parser/DeepAnalysisTest.java
浏览文件 @
a3317a82
...
...
@@ -22,7 +22,7 @@ import java.io.IOException;
import
java.util.List
;
import
org.apache.skywalking.oap.server.core.analysis.metrics.expression.BooleanMatch
;
import
org.apache.skywalking.oap.server.core.analysis.metrics.expression.BooleanNotEqualMatch
;
import
org.apache.skywalking.oap.server.core.analysis.metrics.expression.
Equal
Match
;
import
org.apache.skywalking.oap.server.core.analysis.metrics.expression.
String
Match
;
import
org.apache.skywalking.oap.server.core.analysis.metrics.expression.NotEqualMatch
;
import
org.apache.skywalking.oap.server.core.annotation.AnnotationScan
;
import
org.apache.skywalking.oap.server.core.source.DefaultScopeDefine
;
...
...
@@ -127,7 +127,7 @@ public class DeepAnalysisTest {
List
<
Expression
>
filterExpressions
=
result
.
getFilterExpressions
();
Assert
.
assertEquals
(
1
,
filterExpressions
.
size
());
Expression
filterExpression
=
filterExpressions
.
get
(
0
);
Assert
.
assertEquals
(
Equal
Match
.
class
.
getName
(),
filterExpression
.
getExpressionObject
());
Assert
.
assertEquals
(
String
Match
.
class
.
getName
(),
filterExpression
.
getExpressionObject
());
Assert
.
assertEquals
(
"source.getName()"
,
filterExpression
.
getLeft
());
Assert
.
assertEquals
(
"\"/service/prod/save\""
,
filterExpression
.
getRight
());
}
...
...
@@ -157,7 +157,7 @@ public class DeepAnalysisTest {
result
.
addFilterExpressionsParserResult
(
new
ConditionExpression
(
"stringMatch"
,
"type"
,
""
));
result
=
analysis
.
analysis
(
result
);
assertTrue
(
result
.
getFilterExpressions
().
size
()
>
0
);
assertEquals
(
Equal
Match
.
class
.
getName
(),
result
.
getFilterExpressions
().
get
(
0
).
getExpressionObject
());
assertEquals
(
String
Match
.
class
.
getName
(),
result
.
getFilterExpressions
().
get
(
0
).
getExpressionObject
());
assertEquals
(
"source.getType()"
,
result
.
getFilterExpressions
().
get
(
0
).
getLeft
());
result
.
setFilterExpressions
(
null
);
...
...
oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/parser/ScriptParserTest.java
浏览文件 @
a3317a82
...
...
@@ -269,6 +269,24 @@ public class ScriptParserTest {
Assert
.
assertEquals
(
1
,
methodArgsExpressions
.
size
());
}
@Test
public
void
testParse10
()
throws
IOException
{
ScriptParser
parser
=
ScriptParser
.
createFromScriptText
(
"ClientCpm = from(ServiceInstanceRelation.*).filter(componentId == 7).cpm();"
,
TEST_SOURCE_PACKAGE
);
List
<
AnalysisResult
>
results
=
parser
.
parse
().
getMetricsStmts
();
AnalysisResult
clientCpm
=
results
.
get
(
0
);
Assert
.
assertEquals
(
"ClientCpm"
,
clientCpm
.
getMetricsName
());
Assert
.
assertEquals
(
"ServiceInstanceRelation"
,
clientCpm
.
getSourceName
());
Assert
.
assertEquals
(
"[*]"
,
clientCpm
.
getSourceAttribute
().
toString
());
final
List
<
Expression
>
filterExpressions
=
clientCpm
.
getFilterExpressions
();
Assert
.
assertEquals
(
1
,
filterExpressions
.
size
());
Assert
.
assertEquals
(
"source.getComponentId()"
,
filterExpressions
.
get
(
0
).
getLeft
());
Assert
.
assertEquals
(
"cpm"
,
clientCpm
.
getAggregationFunctionName
());
EntryMethod
entryMethod
=
clientCpm
.
getEntryMethod
();
List
<
Object
>
methodArgsExpressions
=
entryMethod
.
getArgsExpressions
();
Assert
.
assertEquals
(
1
,
methodArgsExpressions
.
size
());
}
@Test
public
void
testDisable
()
throws
IOException
{
ScriptParser
parser
=
ScriptParser
.
createFromScriptText
(
"disable(segment);"
,
TEST_SOURCE_PACKAGE
);
...
...
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/NumberMatch.java
0 → 100644
浏览文件 @
a3317a82
/*
* 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.metrics.expression
;
import
org.apache.skywalking.oap.server.core.analysis.metrics.annotation.FilterMatcher
;
@FilterMatcher
public
class
NumberMatch
{
public
boolean
match
(
int
left
,
int
right
)
{
return
left
==
right
;
}
public
boolean
match
(
long
left
,
long
right
)
{
return
left
==
right
;
}
}
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/
Equal
Match.java
→
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/
String
Match.java
浏览文件 @
a3317a82
...
...
@@ -22,7 +22,7 @@ import java.util.Objects;
import
org.apache.skywalking.oap.server.core.analysis.metrics.annotation.FilterMatcher
;
@FilterMatcher
(
"stringMatch"
)
public
class
Equal
Match
{
public
class
String
Match
{
public
boolean
match
(
String
left
,
String
right
)
{
if
(
left
.
startsWith
(
"\""
)
&&
left
.
endsWith
(
"\""
))
{
...
...
oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/PercentMetricsTest.java
浏览文件 @
a3317a82
...
...
@@ -18,7 +18,7 @@
package
org.apache.skywalking.oap.server.core.analysis.metrics
;
import
org.apache.skywalking.oap.server.core.analysis.metrics.expression.
Equal
Match
;
import
org.apache.skywalking.oap.server.core.analysis.metrics.expression.
String
Match
;
import
org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData
;
import
org.junit.Assert
;
import
org.junit.Test
;
...
...
@@ -27,18 +27,18 @@ public class PercentMetricsTest {
@Test
public
void
testEntranceCombine
()
{
PercentMetricsImpl
impl
=
new
PercentMetricsImpl
();
impl
.
combine
(
new
Equal
Match
().
match
(
true
,
true
));
impl
.
combine
(
new
Equal
Match
().
match
(
true
,
false
));
impl
.
combine
(
new
Equal
Match
().
match
(
true
,
false
));
impl
.
combine
(
new
String
Match
().
match
(
true
,
true
));
impl
.
combine
(
new
String
Match
().
match
(
true
,
false
));
impl
.
combine
(
new
String
Match
().
match
(
true
,
false
));
impl
.
calculate
();
Assert
.
assertEquals
(
3333
,
impl
.
getValue
());
impl
=
new
PercentMetricsImpl
();
impl
.
combine
(
new
Equal
Match
().
match
(
true
,
true
));
impl
.
combine
(
new
Equal
Match
().
match
(
true
,
true
));
impl
.
combine
(
new
Equal
Match
().
match
(
true
,
false
));
impl
.
combine
(
new
String
Match
().
match
(
true
,
true
));
impl
.
combine
(
new
String
Match
().
match
(
true
,
true
));
impl
.
combine
(
new
String
Match
().
match
(
true
,
false
));
impl
.
calculate
();
...
...
@@ -48,14 +48,14 @@ public class PercentMetricsTest {
@Test
public
void
testSelfCombine
()
{
PercentMetricsImpl
impl
=
new
PercentMetricsImpl
();
impl
.
combine
(
new
Equal
Match
().
match
(
true
,
true
));
impl
.
combine
(
new
Equal
Match
().
match
(
true
,
false
));
impl
.
combine
(
new
Equal
Match
().
match
(
true
,
false
));
impl
.
combine
(
new
String
Match
().
match
(
true
,
true
));
impl
.
combine
(
new
String
Match
().
match
(
true
,
false
));
impl
.
combine
(
new
String
Match
().
match
(
true
,
false
));
PercentMetricsImpl
impl2
=
new
PercentMetricsImpl
();
impl2
.
combine
(
new
Equal
Match
().
match
(
true
,
true
));
impl2
.
combine
(
new
Equal
Match
().
match
(
true
,
true
));
impl2
.
combine
(
new
Equal
Match
().
match
(
true
,
false
));
impl2
.
combine
(
new
String
Match
().
match
(
true
,
true
));
impl2
.
combine
(
new
String
Match
().
match
(
true
,
true
));
impl2
.
combine
(
new
String
Match
().
match
(
true
,
false
));
impl
.
combine
(
impl2
);
...
...
oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/NumberMatchTest.java
0 → 100644
浏览文件 @
a3317a82
/*
* 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.metrics.expression
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
public
class
NumberMatchTest
{
@Test
public
void
integerShouldEqual
()
{
Integer
a
=
334
;
Integer
b
=
334
;
boolean
match
=
new
NumberMatch
().
match
(
a
,
b
);
assertTrue
(
match
);
a
=
-
123
;
b
=
-
123
;
match
=
new
NumberMatch
().
match
(
a
,
b
);
assertTrue
(
match
);
a
=
-
122
;
b
=
-
123
;
match
=
new
NumberMatch
().
match
(
a
,
b
);
assertFalse
(
match
);
a
=
-
123
;
b
=
-
122
;
match
=
new
NumberMatch
().
match
(
a
,
b
);
assertFalse
(
match
);
}
@Test
public
void
intShouldEqual
()
{
int
a
=
334
;
int
b
=
334
;
boolean
match
=
new
NumberMatch
().
match
(
a
,
b
);
assertTrue
(
match
);
a
=
-
123
;
b
=
-
123
;
match
=
new
NumberMatch
().
match
(
a
,
b
);
assertTrue
(
match
);
a
=
-
122
;
b
=
-
123
;
match
=
new
NumberMatch
().
match
(
a
,
b
);
assertFalse
(
match
);
a
=
-
123
;
b
=
-
122
;
match
=
new
NumberMatch
().
match
(
a
,
b
);
assertFalse
(
match
);
}
@Test
public
void
longShouldEqual
()
{
long
a
=
21474836478L
;
long
b
=
21474836478L
;
boolean
match
=
new
NumberMatch
().
match
(
a
,
b
);
assertTrue
(
match
);
a
=
-
21474836478L
;
b
=
-
21474836479L
;
match
=
new
NumberMatch
().
match
(
a
,
b
);
assertFalse
(
match
);
Long
c
=
-
123L
;
Long
d
=
-
123L
;
match
=
new
NumberMatch
().
match
(
c
,
d
);
assertTrue
(
match
);
c
=
-
21474836478L
;
d
=
-
21474836479L
;
match
=
new
NumberMatch
().
match
(
c
,
d
);
assertFalse
(
match
);
}
}
\ No newline at end of file
oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/
Equal
MatchTest.java
→
oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/
String
MatchTest.java
浏览文件 @
a3317a82
...
...
@@ -23,13 +23,13 @@ import org.junit.Test;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
public
class
Equal
MatchTest
{
public
class
String
MatchTest
{
@Test
public
void
integerShouldEqualWhenLargerThan128
()
{
Integer
a
=
334
;
Integer
b
=
334
;
boolean
match
=
new
Equal
Match
().
match
(
a
,
b
);
boolean
match
=
new
String
Match
().
match
(
a
,
b
);
assertTrue
(
match
);
}
...
...
@@ -37,7 +37,7 @@ public class EqualMatchTest {
public
void
longShouldEqualWhenLargerThan128
()
{
Long
a
=
334L
;
Long
b
=
334L
;
boolean
match
=
new
Equal
Match
().
match
(
a
,
b
);
boolean
match
=
new
String
Match
().
match
(
a
,
b
);
assertTrue
(
match
);
}
...
...
@@ -45,7 +45,7 @@ public class EqualMatchTest {
public
void
doubleShouldEqualWhenLargerThan128
()
{
Double
a
=
334.0
;
Double
b
=
334.0
;
boolean
match
=
new
Equal
Match
().
match
(
a
,
b
);
boolean
match
=
new
String
Match
().
match
(
a
,
b
);
assertTrue
(
match
);
}
...
...
@@ -53,14 +53,14 @@ public class EqualMatchTest {
public
void
floatShouldEqualWhenLargerThan128
()
{
Float
a
=
334.0
F
;
Float
b
=
334.0
F
;
boolean
match
=
new
Equal
Match
().
match
(
a
,
b
);
boolean
match
=
new
String
Match
().
match
(
a
,
b
);
assertTrue
(
match
);
}
@Test
public
void
stringShouldEqual
()
{
assertTrue
(
new
Equal
Match
().
match
(
"\"a\""
,
"a"
));
assertTrue
(
new
Equal
Match
().
match
(
"a"
,
"a"
));
assertFalse
(
new
Equal
Match
().
match
(
"\"a\""
,
"ab"
));
assertTrue
(
new
String
Match
().
match
(
"\"a\""
,
"a"
));
assertTrue
(
new
String
Match
().
match
(
"a"
,
"a"
));
assertFalse
(
new
String
Match
().
match
(
"\"a\""
,
"ab"
));
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录