Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
a1379630
F
flink
项目概览
doujutun3207
/
flink
与 Fork 源项目一致
从无法访问的项目Fork
通知
24
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
flink
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a1379630
编写于
12月 30, 2020
作者:
P
Piotr Nowojski
提交者:
Piotr Nowojski
1月 06, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FLINK-20718][metrics] Add busyTimeMsPerSecond metric
It's defined as inverted value of idleTimeMsPerSecond
上级
9c68f02c
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
32 addition
and
1 deletion
+32
-1
docs/ops/metrics.md
docs/ops/metrics.md
+5
-0
docs/ops/metrics.zh.md
docs/ops/metrics.zh.md
+5
-0
flink-runtime/src/main/java/org/apache/flink/runtime/metrics/MetricNames.java
...in/java/org/apache/flink/runtime/metrics/MetricNames.java
+1
-0
flink-runtime/src/main/java/org/apache/flink/runtime/metrics/groups/TaskIOMetricGroup.java
...pache/flink/runtime/metrics/groups/TaskIOMetricGroup.java
+14
-0
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/SourceStreamTask.java
...pache/flink/streaming/runtime/tasks/SourceStreamTask.java
+2
-0
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java
.../org/apache/flink/streaming/runtime/tasks/StreamTask.java
+2
-0
flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/SourceStreamTaskTest.java
...e/flink/streaming/runtime/tasks/SourceStreamTaskTest.java
+3
-1
未找到文件。
docs/ops/metrics.md
浏览文件 @
a1379630
...
...
@@ -1258,6 +1258,11 @@ Certain RocksDB native metrics are available but disabled by default, you can fi
<td>
The time (in milliseconds) this task is back pressured per second.
</td>
<td>
Meter
</td>
</tr>
<tr>
<td>
busyTimeMsPerSecond
</td>
<td>
The time (in milliseconds) this task is busy (neither idle nor back pressured) per second. Can be NaN, if the value could not be calculated.
</td>
<td>
Meter
</td>
</tr>
<tr>
<th
rowspan=
"6"
><strong>
Task/Operator
</strong></th>
<td>
numRecordsIn
</td>
...
...
docs/ops/metrics.zh.md
浏览文件 @
a1379630
...
...
@@ -1258,6 +1258,11 @@ Certain RocksDB native metrics are available but disabled by default, you can fi
<td>
The time (in milliseconds) this task is back pressured per second.
</td>
<td>
Meter
</td>
</tr>
<tr>
<td>
busyTimeMsPerSecond
</td>
<td>
The time (in milliseconds) this task is busy (neither idle nor back pressured) per second. Can be NaN, if the value could not be calculated.
</td>
<td>
Meter
</td>
</tr>
<tr>
<th
rowspan=
"6"
><strong>
Task/Operator
</strong></th>
<td>
numRecordsIn
</td>
...
...
flink-runtime/src/main/java/org/apache/flink/runtime/metrics/MetricNames.java
浏览文件 @
a1379630
...
...
@@ -67,5 +67,6 @@ public class MetricNames {
}
public
static
final
String
TASK_IDLE_TIME
=
"idleTimeMs"
+
SUFFIX_RATE
;
public
static
final
String
TASK_BUSY_TIME
=
"busyTimeMs"
+
SUFFIX_RATE
;
public
static
final
String
TASK_BACK_PRESSURED_TIME
=
"backPressuredTimeMs"
+
SUFFIX_RATE
;
}
flink-runtime/src/main/java/org/apache/flink/runtime/metrics/groups/TaskIOMetricGroup.java
浏览文件 @
a1379630
...
...
@@ -19,6 +19,7 @@
package
org.apache.flink.runtime.metrics.groups
;
import
org.apache.flink.metrics.Counter
;
import
org.apache.flink.metrics.Gauge
;
import
org.apache.flink.metrics.Meter
;
import
org.apache.flink.metrics.MeterView
;
import
org.apache.flink.metrics.SimpleCounter
;
...
...
@@ -46,8 +47,11 @@ public class TaskIOMetricGroup extends ProxyMetricGroup<TaskMetricGroup> {
private
final
Meter
numRecordsOutRate
;
private
final
Meter
numBuffersOutRate
;
private
final
Meter
idleTimePerSecond
;
private
final
Gauge
busyTimePerSecond
;
private
final
Meter
backPressuredTimePerSecond
;
private
volatile
boolean
busyTimeEnabled
;
public
TaskIOMetricGroup
(
TaskMetricGroup
parent
)
{
super
(
parent
);
...
...
@@ -71,6 +75,7 @@ public class TaskIOMetricGroup extends ProxyMetricGroup<TaskMetricGroup> {
meter
(
MetricNames
.
TASK_IDLE_TIME
,
new
MeterView
(
new
SimpleCounter
()));
this
.
backPressuredTimePerSecond
=
meter
(
MetricNames
.
TASK_BACK_PRESSURED_TIME
,
new
MeterView
(
new
SimpleCounter
()));
this
.
busyTimePerSecond
=
gauge
(
MetricNames
.
TASK_BUSY_TIME
,
this
::
getBusyTimePerSecond
);
}
public
IOMetrics
createSnapshot
()
{
...
...
@@ -109,6 +114,15 @@ public class TaskIOMetricGroup extends ProxyMetricGroup<TaskMetricGroup> {
return
backPressuredTimePerSecond
;
}
public
void
setEnableBusyTime
(
boolean
enabled
)
{
busyTimeEnabled
=
enabled
;
}
private
double
getBusyTimePerSecond
()
{
double
busyTime
=
idleTimePerSecond
.
getRate
()
+
backPressuredTimePerSecond
.
getRate
();
return
busyTimeEnabled
?
1000.0
-
Math
.
min
(
busyTime
,
1000.0
)
:
Double
.
NaN
;
}
// ============================================================================================
// Metric Reuse
// ============================================================================================
...
...
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/SourceStreamTask.java
浏览文件 @
a1379630
...
...
@@ -80,6 +80,8 @@ public class SourceStreamTask<
StreamTaskActionExecutor
.
synchronizedExecutor
(
lock
));
this
.
lock
=
Preconditions
.
checkNotNull
(
lock
);
this
.
sourceThread
=
new
LegacySourceFunctionThread
();
getEnvironment
().
getMetricGroup
().
getIOMetricGroup
().
setEnableBusyTime
(
false
);
}
@Override
...
...
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java
浏览文件 @
a1379630
...
...
@@ -343,6 +343,8 @@ public abstract class StreamTask<OUT, OP extends StreamOperator<OUT>> extends Ab
new
ExecutorThreadFactory
(
"channel-state-unspilling"
));
injectChannelStateWriterIntoChannels
();
environment
.
getMetricGroup
().
getIOMetricGroup
().
setEnableBusyTime
(
true
);
}
private
void
injectChannelStateWriterIntoChannels
()
{
...
...
flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/SourceStreamTaskTest.java
浏览文件 @
a1379630
...
...
@@ -110,7 +110,7 @@ public class SourceStreamTaskTest {
}
@Test
(
timeout
=
60_000
)
public
void
test
StartDelayMetric
()
throws
Exception
{
public
void
test
Metrics
()
throws
Exception
{
long
sleepTime
=
42
;
StreamTaskMailboxTestHarnessBuilder
<
String
>
builder
=
new
StreamTaskMailboxTestHarnessBuilder
<>(
...
...
@@ -145,6 +145,8 @@ public class SourceStreamTaskTest {
(
Gauge
<
Long
>)
metrics
.
get
(
MetricNames
.
CHECKPOINT_START_DELAY_TIME
);
assertThat
(
checkpointStartDelayGauge
.
getValue
(),
greaterThanOrEqualTo
(
sleepTime
*
1_000_000
));
Gauge
<
Double
>
busyTimeGauge
=
(
Gauge
<
Double
>)
metrics
.
get
(
MetricNames
.
TASK_BUSY_TIME
);
assertTrue
(
Double
.
isNaN
(
busyTimeGauge
.
getValue
()));
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录