Skip to content

Commit

Permalink
Merge pull request #796 from input-output-hk/etcm-339-checkpointing-m…
Browse files Browse the repository at this point in the history
…etrics

[ETCM-339] [Metrics] Add metrics related to checkpointing blocks at mantis level
  • Loading branch information
pslaski committed Nov 17, 2020
2 parents 2047259 + 65a07b6 commit ac691fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/scala/io/iohk/ethereum/ledger/BlockImport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class BlockImport(
)

if (importedBlocks.nonEmpty) {
importedBlocks.map(blockData => BlockMetrics.measure(blockData.block, blockchain.getBlockByHash))
importedBlocks.foreach(blockData => BlockMetrics.measure(blockData.block, blockchain.getBlockByHash))
}

result
Expand Down
4 changes: 4 additions & 0 deletions src/main/scala/io/iohk/ethereum/ledger/BlockMetrics.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ case object BlockMetrics extends MetricsContainer {

private[this] final val BlockNumberGauge =
metrics.registry.gauge("sync.block.number.gauge", new AtomicDouble(0d))
private[this] final val CheckpointBlockNumberGauge =
metrics.registry.gauge("sync.block.checkpoint.number.gauge", new AtomicDouble(0d))
private[this] final val BlockGasLimitGauge =
metrics.registry.gauge("sync.block.gasLimit.gauge", new AtomicDouble(0d))
private[this] final val BlockGasUsedGauge =
Expand All @@ -24,6 +26,8 @@ case object BlockMetrics extends MetricsContainer {

def measure(block: Block, getBlockByHashFn: ByteString => Option[Block]): Unit = {
BlockNumberGauge.set(block.number.toDouble)
if (block.hasCheckpoint)
CheckpointBlockNumberGauge.set(block.number.toDouble)
BlockGasLimitGauge.set(block.header.gasLimit.toDouble)
BlockGasUsedGauge.set(block.header.gasUsed.toDouble)
BlockDifficultyGauge.set(block.header.difficulty.toDouble)
Expand Down

0 comments on commit ac691fd

Please sign in to comment.