Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Add metrics to assist monitoring and alerting #1506

Merged
merged 2 commits into from
May 29, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -63,18 +63,18 @@ public DefaultMutableBlockchain(
chainHeader = blockchainStorage.getBlockHeader(chainHead).get();
totalDifficulty = blockchainStorage.getTotalDifficulty(chainHead).get();

metricsSystem.createGauge(
metricsSystem.createLongGauge(
MetricCategory.BLOCKCHAIN,
"height",
"Height of the chainhead",
() -> (double) this.getChainHeadBlockNumber());
metricsSystem.createGauge(
this::getChainHeadBlockNumber);
metricsSystem.createLongGauge(
MetricCategory.BLOCKCHAIN,
"difficulty_total",
"Total difficulty of the chainhead",
() ->
BytesValues.asUnsignedBigInteger(this.getChainHead().getTotalDifficulty().getBytes())
.doubleValue());
.longValue());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import tech.pegasys.pantheon.ethereum.eth.sync.state.SyncState;
import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSchedule;
import tech.pegasys.pantheon.ethereum.worldstate.WorldStateStorage;
import tech.pegasys.pantheon.metrics.MetricCategory;
import tech.pegasys.pantheon.metrics.MetricsSystem;
import tech.pegasys.pantheon.util.ExceptionUtils;
import tech.pegasys.pantheon.util.Subscribers;
Expand Down Expand Up @@ -95,6 +96,17 @@ public DefaultSynchronizer(
worldStateStorage,
syncState,
clock);

metricsSystem.createLongGauge(
MetricCategory.SYNCHRONIZER,
"best_known_block",
"Height of best known block from any connected peer",
() -> syncState.syncStatus().getHighestBlock());
metricsSystem.createIntegerGauge(
MetricCategory.SYNCHRONIZER,
"in_sync",
"Whether or not the local node has caught up to the best known peer",
() -> getSyncStatus().isPresent() ? 0 : 1);
}

private TrailingPeerRequirements calculateTrailingPeerRequirements() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,12 @@ public class DefaultP2PNetwork implements P2PNetwork {
"netty_boss_pending_tasks",
"The number of pending tasks in the Netty boss event loop",
pendingTaskCounter(boss));

metricsSystem.createIntegerGauge(
MetricCategory.NETWORK,
"peers_limit",
"Maximum P2P peer connections that can be established",
() -> maxPeers);
}

public static Builder builder() {
Expand Down