Repository: kafka Updated Branches: refs/heads/trunk 1ac2640f8 -> 7a36d3647
MINOR: Expose ReplicaManager gauges There are several gauges in core that are registered but cannot be accessed programmatically. For example, gauges "LeaderCount", "PartitionCount", "UnderReplicatedParittions" are all registered in ReplicaManager.scala but there is no way to access them programmatically if one has access to the kafka.server object. Other metrics, such as isrExpandRate (also in ReplicaManager.scala) can be accessed. The solution here is trivial, add a var <variable name> in front of newGauge, as shown below val partitionCount newGauge( "PartitionCount", new Gauge[Int] { def value = allPartitions.size } ) Author: Eno Thereska <eno.there...@gmail.com> Reviewers: Ismael Juma, Guozhang Wang Closes #364 from enothereska/gauges Project: http://git-wip-us.apache.org/repos/asf/kafka/repo Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/7a36d364 Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/7a36d364 Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/7a36d364 Branch: refs/heads/trunk Commit: 7a36d36478635ae16b64c6410b88c92b45d5f129 Parents: 1ac2640 Author: Eno Thereska <eno.there...@gmail.com> Authored: Tue Oct 27 17:55:59 2015 -0700 Committer: Guozhang Wang <wangg...@gmail.com> Committed: Tue Oct 27 17:55:59 2015 -0700 ---------------------------------------------------------------------- core/src/main/scala/kafka/server/ReplicaManager.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kafka/blob/7a36d364/core/src/main/scala/kafka/server/ReplicaManager.scala ---------------------------------------------------------------------- diff --git a/core/src/main/scala/kafka/server/ReplicaManager.scala b/core/src/main/scala/kafka/server/ReplicaManager.scala index 1fc47f4..0413b1a 100644 --- a/core/src/main/scala/kafka/server/ReplicaManager.scala +++ b/core/src/main/scala/kafka/server/ReplicaManager.scala @@ -122,7 +122,7 @@ class ReplicaManager(val config: KafkaConfig, val delayedFetchPurgatory = new DelayedOperationPurgatory[DelayedFetch]( purgatoryName = "Fetch", config.brokerId, config.fetchPurgatoryPurgeIntervalRequests) - newGauge( + val leaderCount = newGauge( "LeaderCount", new Gauge[Int] { def value = { @@ -130,13 +130,13 @@ class ReplicaManager(val config: KafkaConfig, } } ) - newGauge( + val partitionCount = newGauge( "PartitionCount", new Gauge[Int] { def value = allPartitions.size } ) - newGauge( + val underReplicatedPartitions = newGauge( "UnderReplicatedPartitions", new Gauge[Int] { def value = underReplicatedPartitionCount()