Skip to content

Commit

Permalink
Metric should be a gauge not a counter
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
  • Loading branch information
matthew1001 committed Oct 9, 2024
1 parent a6552df commit 9a4c6b8
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.hyperledger.besu.ethereum.trie.diffbased.common.trielog.TrieLogManager;
import org.hyperledger.besu.metrics.BesuMetricCategory;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.plugin.services.metrics.Counter;
import org.hyperledger.besu.plugin.services.trielogs.TrieLog;

import java.util.Optional;
Expand Down Expand Up @@ -56,7 +55,6 @@ public class BonsaiArchiver implements BlockAddedObserver {
private static final int DISTANCE_FROM_HEAD_BEFORE_ARCHIVING_OLD_STATE = 10;
private final TrieLogManager trieLogManager;
protected final MetricsSystem metricsSystem;
protected final Counter archivedBlocksCounter;

// For logging progress. Saves doing a DB read just to record our progress
final AtomicLong latestArchivedBlock = new AtomicLong(0);
Expand All @@ -73,11 +71,11 @@ public BonsaiArchiver(
this.trieLogManager = trieLogManager;
this.metricsSystem = metricsSystem;

archivedBlocksCounter =
metricsSystem.createCounter(
BesuMetricCategory.BLOCKCHAIN,
"archived_blocks_state_total",
"Total number of blocks for which state has been archived");
metricsSystem.createLongGauge(
BesuMetricCategory.BLOCKCHAIN,
"archived_blocks_state_total",
"Total number of blocks for which state has been archived",
() -> latestArchivedBlock.get());
}

public void initialize() {
Expand Down

0 comments on commit 9a4c6b8

Please sign in to comment.