Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
d8a5e8c1
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,发现更多精彩内容 >>
未验证
提交
d8a5e8c1
编写于
6月 24, 2021
作者:
D
Daming
提交者:
GitHub
6月 24, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
eliminate `now` error at a fixed rate schedule executor (#7145)
上级
3541c325
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
150 addition
and
7 deletion
+150
-7
CHANGES.md
CHANGES.md
+1
-0
oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/dsl/Sample.java
.../org/apache/skywalking/oap/meter/analyzer/dsl/Sample.java
+6
-0
oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/dsl/SampleFamily.java
...pache/skywalking/oap/meter/analyzer/dsl/SampleFamily.java
+14
-1
oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/dsl/counter/CounterWindow.java
...walking/oap/meter/analyzer/dsl/counter/CounterWindow.java
+33
-6
oap-server/analyzer/meter-analyzer/src/test/java/org/apache/skywalking/oap/meter/analyzer/dsl/counter/CounterWindowTest.java
...ing/oap/meter/analyzer/dsl/counter/CounterWindowTest.java
+96
-0
未找到文件。
CHANGES.md
浏览文件 @
d8a5e8c1
...
@@ -42,6 +42,7 @@ Release Notes.
...
@@ -42,6 +42,7 @@ Release Notes.
*
Upgrade commons-lang3 to avoid potential NPE in some JDK versions.
*
Upgrade commons-lang3 to avoid potential NPE in some JDK versions.
*
OAL supports generating metrics from events.
*
OAL supports generating metrics from events.
*
Support endpoint name grouping by OpenAPI definitions.
*
Support endpoint name grouping by OpenAPI definitions.
*
Fix CounterWindow increase computing issue.
#### UI
#### UI
*
Fix the date component for log conditions.
*
Fix the date component for log conditions.
...
...
oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/dsl/Sample.java
浏览文件 @
d8a5e8c1
...
@@ -51,4 +51,10 @@ public class Sample {
...
@@ -51,4 +51,10 @@ public class Sample {
double
nv
=
transform
.
apply
(
i
.
_2
,
i
.
_1
);
double
nv
=
transform
.
apply
(
i
.
_2
,
i
.
_1
);
return
newValue
(
ignored
->
nv
);
return
newValue
(
ignored
->
nv
);
}
}
Sample
increase
(
Function2
<
Double
,
Long
,
Double
>
transform
)
{
Tuple2
<
Long
,
Double
>
i
=
CounterWindow
.
INSTANCE
.
pop
(
name
,
labels
,
value
,
timestamp
);
double
nv
=
transform
.
apply
(
i
.
_2
,
i
.
_1
);
return
newValue
(
ignored
->
nv
);
}
}
}
oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/dsl/SampleFamily.java
浏览文件 @
d8a5e8c1
...
@@ -288,7 +288,20 @@ public class SampleFamily {
...
@@ -288,7 +288,20 @@ public class SampleFamily {
}
}
public
SampleFamily
irate
()
{
public
SampleFamily
irate
()
{
return
rate
(
"PT1S"
);
if
(
this
==
EMPTY
)
{
return
EMPTY
;
}
return
SampleFamily
.
build
(
this
.
context
,
Arrays
.
stream
(
samples
)
.
map
(
sample
->
sample
.
increase
(
(
lowerBoundValue
,
lowerBoundTime
)
->
{
final
long
timeDiff
=
(
sample
.
timestamp
-
lowerBoundTime
)
/
1000
;
return
timeDiff
<
1L
?
0.0
:
(
sample
.
value
-
lowerBoundValue
)
/
timeDiff
;
}
))
.
toArray
(
Sample
[]::
new
)
);
}
}
@SuppressWarnings
(
value
=
"unchecked"
)
@SuppressWarnings
(
value
=
"unchecked"
)
...
...
oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/dsl/counter/CounterWindow.java
浏览文件 @
d8a5e8c1
...
@@ -22,8 +22,8 @@ import com.google.common.collect.ImmutableMap;
...
@@ -22,8 +22,8 @@ import com.google.common.collect.ImmutableMap;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Maps
;
import
io.vavr.Tuple
;
import
io.vavr.Tuple
;
import
io.vavr.Tuple2
;
import
io.vavr.Tuple2
;
import
java.util.LinkedList
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.PriorityQueue
;
import
java.util.Queue
;
import
java.util.Queue
;
import
lombok.AccessLevel
;
import
lombok.AccessLevel
;
import
lombok.EqualsAndHashCode
;
import
lombok.EqualsAndHashCode
;
...
@@ -42,20 +42,47 @@ public class CounterWindow {
...
@@ -42,20 +42,47 @@ public class CounterWindow {
public
static
final
CounterWindow
INSTANCE
=
new
CounterWindow
();
public
static
final
CounterWindow
INSTANCE
=
new
CounterWindow
();
private
final
Map
<
ID
,
Tuple2
<
Long
,
Double
>>
lastElementMap
=
Maps
.
newHashMap
();
private
final
Map
<
ID
,
Queue
<
Tuple2
<
Long
,
Double
>>>
windows
=
Maps
.
newHashMap
();
private
final
Map
<
ID
,
Queue
<
Tuple2
<
Long
,
Double
>>>
windows
=
Maps
.
newHashMap
();
public
Tuple2
<
Long
,
Double
>
increase
(
String
name
,
ImmutableMap
<
String
,
String
>
labels
,
Double
value
,
long
windowSize
,
long
now
)
{
public
Tuple2
<
Long
,
Double
>
increase
(
String
name
,
ImmutableMap
<
String
,
String
>
labels
,
Double
value
,
long
windowSize
,
long
now
)
{
ID
id
=
new
ID
(
name
,
labels
);
ID
id
=
new
ID
(
name
,
labels
);
if
(!
windows
.
containsKey
(
id
))
{
if
(!
windows
.
containsKey
(
id
))
{
windows
.
put
(
id
,
new
LinkedList
<>());
windows
.
put
(
id
,
new
PriorityQueue
<>());
}
}
Queue
<
Tuple2
<
Long
,
Double
>>
window
=
windows
.
get
(
id
);
Queue
<
Tuple2
<
Long
,
Double
>>
window
=
windows
.
get
(
id
);
window
.
offer
(
Tuple
.
of
(
now
,
value
));
window
.
offer
(
Tuple
.
of
(
now
,
value
));
Tuple2
<
Long
,
Double
>
ps
=
window
.
element
();
long
waterLevel
=
now
-
windowSize
;
if
((
now
-
ps
.
_1
)
>=
windowSize
)
{
Tuple2
<
Long
,
Double
>
peek
=
window
.
peek
();
window
.
remove
();
if
(
peek
.
_1
>
waterLevel
)
{
return
peek
;
}
Tuple2
<
Long
,
Double
>
result
=
peek
;
while
(
peek
.
_1
<
waterLevel
)
{
result
=
window
.
poll
();
peek
=
window
.
element
();
}
// Choose the closed slot to the expected timestamp
if
(
waterLevel
-
result
.
_1
<=
peek
.
_1
-
waterLevel
)
{
return
result
;
}
return
peek
;
}
public
Tuple2
<
Long
,
Double
>
pop
(
String
name
,
ImmutableMap
<
String
,
String
>
labels
,
Double
value
,
long
now
)
{
ID
id
=
new
ID
(
name
,
labels
);
Tuple2
<
Long
,
Double
>
element
=
Tuple
.
of
(
now
,
value
);
Tuple2
<
Long
,
Double
>
result
=
lastElementMap
.
get
(
id
);
lastElementMap
.
put
(
id
,
element
);
if
(
result
==
null
)
{
return
element
;
}
}
return
ps
;
return
result
;
}
}
public
void
reset
()
{
public
void
reset
()
{
...
...
oap-server/analyzer/meter-analyzer/src/test/java/org/apache/skywalking/oap/meter/analyzer/dsl/counter/CounterWindowTest.java
0 → 100644
浏览文件 @
d8a5e8c1
/*
* 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.meter.analyzer.dsl.counter
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.Lists
;
import
io.vavr.Tuple2
;
import
java.time.Duration
;
import
java.util.List
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
static
java
.
time
.
Instant
.
parse
;
public
class
CounterWindowTest
{
public
static
List
<
Tuple2
<
Long
,
Double
>>
parameters
()
{
return
Lists
.
newArrayList
(
new
Tuple2
<>(
parse
(
"2020-09-11T11:11:01.03Z"
).
toEpochMilli
(),
10
d
),
new
Tuple2
<>(
parse
(
"2020-09-11T11:11:15.99Z"
).
toEpochMilli
(),
11
d
),
new
Tuple2
<>(
parse
(
"2020-09-11T11:11:31.00Z"
).
toEpochMilli
(),
12
d
),
new
Tuple2
<>(
parse
(
"2020-09-11T11:11:46.09Z"
).
toEpochMilli
(),
13
d
),
new
Tuple2
<>(
parse
(
"2020-09-11T11:12:00.97Z"
).
toEpochMilli
(),
14
d
),
new
Tuple2
<>(
parse
(
"2020-09-11T11:11:00.97Z"
).
toEpochMilli
(),
15
d
),
new
Tuple2
<>(
parse
(
"2020-09-11T11:12:16.60Z"
).
toEpochMilli
(),
16
d
),
new
Tuple2
<>(
parse
(
"2020-09-11T11:12:31.66Z"
).
toEpochMilli
(),
17
d
)
);
}
@Test
public
void
testPT15S
()
{
double
[]
actuals
=
parameters
().
stream
().
mapToDouble
(
e
->
{
Tuple2
<
Long
,
Double
>
increase
=
CounterWindow
.
INSTANCE
.
increase
(
"test"
,
ImmutableMap
.<
String
,
String
>
builder
().
build
(),
e
.
_2
,
Duration
.
parse
(
"PT15S"
).
getSeconds
()
*
1000
,
e
.
_1
);
return
e
.
_2
-
increase
.
_2
;
}).
toArray
();
Assert
.
assertArrayEquals
(
new
double
[]
{
0
,
1
d
,
1
d
,
1
d
,
1
d
,
0
d
,
2
d
,
1
d
},
actuals
,
0
.
d
);
}
@Test
public
void
testPT35S
()
{
double
[]
actuals
=
parameters
().
stream
().
mapToDouble
(
e
->
{
Tuple2
<
Long
,
Double
>
increase
=
CounterWindow
.
INSTANCE
.
increase
(
"test"
,
ImmutableMap
.<
String
,
String
>
builder
().
build
(),
e
.
_2
,
Duration
.
parse
(
"PT35S"
).
getSeconds
()
*
1000
,
e
.
_1
);
return
e
.
_2
-
increase
.
_2
;
}).
toArray
();
Assert
.
assertArrayEquals
(
new
double
[]
{
0
,
1
d
,
2
d
,
2
d
,
2
d
,
0
d
,
3
d
,
3
d
},
actuals
,
0
.
d
);
}
@Test
public
void
testPT1M
()
{
double
[]
actuals
=
parameters
().
stream
().
mapToDouble
(
e
->
{
Tuple2
<
Long
,
Double
>
increase
=
CounterWindow
.
INSTANCE
.
increase
(
"test"
,
ImmutableMap
.<
String
,
String
>
builder
().
build
(),
e
.
_2
,
Duration
.
parse
(
"PT1M"
).
getSeconds
()
*
1000
,
e
.
_1
);
return
e
.
_2
-
increase
.
_2
;
}).
toArray
();
Assert
.
assertArrayEquals
(
new
double
[]
{
0
,
1
d
,
2
d
,
3
d
,
4
d
,
0
d
,
5
d
,
5
d
},
actuals
,
0
.
d
);
}
@Test
public
void
testPT2M
()
{
double
[]
actuals
=
parameters
().
stream
().
mapToDouble
(
e
->
{
Tuple2
<
Long
,
Double
>
increase
=
CounterWindow
.
INSTANCE
.
increase
(
"test"
,
ImmutableMap
.<
String
,
String
>
builder
().
build
(),
e
.
_2
,
Duration
.
parse
(
"PT2M"
).
getSeconds
()
*
1000
,
e
.
_1
);
return
e
.
_2
-
increase
.
_2
;
}).
toArray
();
Assert
.
assertArrayEquals
(
new
double
[]
{
0
,
1
d
,
2
d
,
3
d
,
4
d
,
0
d
,
1
d
,
2
d
},
actuals
,
0
.
d
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录