Skip to content

Commit 71dfe6b

Browse files
committed
Don't increment podHealthChecked metric on internal check (do it only for unresponsive pods)
1 parent 35ba2c0 commit 71dfe6b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

manager/src/main/scala/com/devsisters/shardcake/ShardManager.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ class ShardManager(
4848
ZIO.fail(new RuntimeException(s"Pod $pod is not healthy, refusing to register"))
4949
)
5050

51-
def notifyUnhealthyPod(podAddress: PodAddress): UIO[Unit] =
51+
def notifyUnhealthyPod(podAddress: PodAddress, ignoreMetric: Boolean = false): UIO[Unit] =
5252
ZIO
5353
.whenZIODiscard(stateRef.get.map(_.pods.contains(podAddress))) {
54-
ManagerMetrics.podHealthChecked.tagged("pod_address", podAddress.toString).increment *>
54+
ManagerMetrics.podHealthChecked.tagged("pod_address", podAddress.toString).increment.unless(ignoreMetric) *>
5555
eventsHub.publish(ShardingEvent.PodHealthChecked(podAddress)) *>
5656
ZIO.unlessZIO(healthApi.isAlive(podAddress))(
5757
ZIO.logWarning(s"Pod $podAddress is not alive, unregistering") *> unregister(podAddress)
@@ -61,7 +61,7 @@ class ShardManager(
6161
def checkAllPodsHealth: UIO[Unit] =
6262
for {
6363
pods <- stateRef.get.map(_.pods.keySet)
64-
_ <- ZIO.foreachParDiscard(pods)(notifyUnhealthyPod).withParallelism(4)
64+
_ <- ZIO.foreachParDiscard(pods)(notifyUnhealthyPod(_, ignoreMetric = true)).withParallelism(4)
6565
} yield ()
6666

6767
def unregister(podAddress: PodAddress): UIO[Unit] =

0 commit comments

Comments
 (0)