This is an automated email from the ASF dual-hosted git repository.
lindong pushed a commit to branch 1.1
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/1.1 by this push:
new 237ec86 KAFKA-7354; Fix IdlePercent and
NetworkProcessorAvgIdlePercent metric
237ec86 is described below
commit 237ec863fce8e2d5201901d51bcf6807f65715ac
Author: huxihx <[email protected]>
AuthorDate: Wed Aug 29 08:29:59 2018 -0700
KAFKA-7354; Fix IdlePercent and NetworkProcessorAvgIdlePercent metric
Currently, MBean
`kafka.network:type=Processor,name=IdlePercent,networkProcessor=*` and
`afka.network:type=SocketServer,name=NetworkProcessorAvgIdlePercent` could be
greater than 1. However, these two values represent a percentage which should
not exceed 1.
Author: huxihx <[email protected]>
Reviewers: Dong Lin <[email protected]>
Closes #5584 from huxihx/KAFKA-7354
(cherry picked from commit d0fcf12832d9d383a5c76c174119e96e36d94eaf)
Signed-off-by: Dong Lin <[email protected]>
---
core/src/main/scala/kafka/network/SocketServer.scala | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/core/src/main/scala/kafka/network/SocketServer.scala
b/core/src/main/scala/kafka/network/SocketServer.scala
index 8b2d402..e4d4786 100644
--- a/core/src/main/scala/kafka/network/SocketServer.scala
+++ b/core/src/main/scala/kafka/network/SocketServer.scala
@@ -104,7 +104,7 @@ class SocketServer(val config: KafkaConfig, val metrics:
Metrics, val time: Time
metrics.metricName("io-wait-ratio", "socket-server-metrics",
p.metricTags)
}
ioWaitRatioMetricNames.map { metricName =>
- Option(metrics.metric(metricName)).fold(0.0)(_.value)
+ Option(metrics.metric(metricName)).fold(0.0)(m =>
Math.min(m.metricValue.asInstanceOf[Double], 1.0))
}.sum / processors.size
}
}
@@ -530,7 +530,8 @@ private[kafka] class Processor(val id: Int,
newGauge(IdlePercentMetricName,
new Gauge[Double] {
def value = {
- Option(metrics.metric(metrics.metricName("io-wait-ratio",
"socket-server-metrics", metricTags))).fold(0.0)(_.value)
+ Option(metrics.metric(metrics.metricName("io-wait-ratio",
"socket-server-metrics", metricTags)))
+ .fold(0.0)(m => Math.min(m.metricValue.asInstanceOf[Double], 1.0))
}
},
// for compatibility, only add a networkProcessor tag to the Yammer
Metrics alias (the equivalent Selector metric