Skip to content

Commit 3a9b0a6

Browse files
authored
Added consensus-client.chain-id metric (#59)
1 parent 00187c8 commit 3a9b0a6

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

build.sbt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ inScope(Global)(
1919
"-unchecked",
2020
"-language:higherKinds",
2121
"-language:implicitConversions",
22-
"-language:postfixOps"
22+
"-language:postfixOps",
23+
"-language:experimental.namedTuples"
2324
)
2425
)
2526
)

src/main/scala/units/ELUpdater.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import com.wavesplatform.utx.UtxPool
2222
import com.wavesplatform.wallet.Wallet
2323
import io.netty.channel.Channel
2424
import io.netty.channel.group.DefaultChannelGroup
25+
import kamon.Kamon
2526
import monix.execution.cancelables.SerialCancelable
2627
import monix.execution.{CancelableFuture, Scheduler}
2728
import play.api.libs.json.*
@@ -1735,6 +1736,18 @@ class ELUpdater(
17351736

17361737
private def setState(label: String, newState: State): Unit = {
17371738
logger.trace(s"New state after $label: $newState")
1739+
val chainIdOpt = newState match {
1740+
case Working(chainStatus = cs) =>
1741+
cs match {
1742+
case FollowingChain(nodeChainInfo = ChainInfo(id = id)) => Some(id)
1743+
case Mining(nodeChainInfo = Right(nci)) => Some(nci.id)
1744+
case _ => None
1745+
}
1746+
case _ => None
1747+
}
1748+
1749+
chainIdOpt.foreach(chainId => Kamon.gauge("consensus-client.chain-id").withTag("chain-contract", config.chainContract).update(chainId.toDouble))
1750+
17381751
state = newState
17391752
}
17401753
}

0 commit comments

Comments
 (0)