Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

Filter Out NaN Values from Aggregate Metrics #158

Merged
merged 2 commits into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,11 @@ object ConsumerGroupCollector {
reporter ! Metrics.GroupValueMessage(Metrics.MaxGroupOffsetLagMetric, config.cluster.name, group, maxOffsetLag.offsetLag)
reporter ! Metrics.GroupValueMessage(Metrics.MaxGroupTimeLagMetric, config.cluster.name, group, maxTimeLag.timeLag)

val sumOffsetLag = groupValues.map(_.offsetLag).sum
val sumOffsetLag = groupValues.map(_.offsetLag).filter(offsetLag => !offsetLag.isNaN).sum
reporter ! Metrics.GroupValueMessage(Metrics.SumGroupOffsetLagMetric, config.cluster.name, group, sumOffsetLag)

for((topic, topicValues) <- groupValues.groupBy(_.gtp.topic)) {
val topicOffsetLag = topicValues.map(_.offsetLag).sum
val topicOffsetLag = topicValues.map(_.offsetLag).filter(offsetLag => !offsetLag.isNaN).sum

reporter ! Metrics.GroupTopicValueMessage(Metrics.SumGroupTopicOffsetLagMetric, config.cluster.name, group, topic, topicOffsetLag)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class ConsumerGroupCollectorSpec extends FreeSpec with Matchers with TestData wi

"topic offset lag metric" in {
metrics.collectFirst {
case GroupTopicValueMessage(`SumGroupTopicOffsetLagMetric`, config.cluster.name, `groupId`, `topic`, value) if value.isNaN => true
case GroupTopicValueMessage(`SumGroupTopicOffsetLagMetric`, config.cluster.name, `groupId`, `topic`, value) if !value.isNaN => true
}.nonEmpty shouldBe true
}
}
Expand Down