Skip to content

Commit

Permalink
added node info metric
Browse files Browse the repository at this point in the history
  • Loading branch information
paolocappelletti committed Apr 19, 2024
1 parent 7784264 commit 3745448
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sdk/src/main/java/io/horizen/metrics/MetricsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.prometheus.metrics.core.metrics.Counter;
import io.prometheus.metrics.core.metrics.Gauge;
import io.prometheus.metrics.core.metrics.Info;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import sparkz.core.utils.TimeProvider;
Expand All @@ -16,6 +17,8 @@ public class MetricsManager {

private TimeProvider timeProvider;
private static MetricsManager me;

private Info nodeInfo;
private Counter blocksAppliedSuccessfully;
private Counter blocksNotApplied;
private Gauge blockApplyTime;
Expand Down Expand Up @@ -47,6 +50,9 @@ private MetricsManager(TimeProvider timeProvider) throws IOException {
//JvmMetrics.builder().register(); // initialize the out-of-the-box JVM metrics
helps = new ArrayList<>();

nodeInfo = Info.builder().name("node_info").labelNames("version", "sdkVersion", "architecture", "jdkVersion").register();
helps.add(new MetricsHelp(nodeInfo.getPrometheusName(), "Node version"));

blockApplyTime = Gauge.builder().name("block_apply_time").register();
helps.add(new MetricsHelp(blockApplyTime.getPrometheusName(), "Time to apply block to node wallet and state (milliseconds)"));

Expand Down Expand Up @@ -83,6 +89,7 @@ public void appliedBlockOk(long millis, long millisFromBlockStamp){
blocksAppliedSuccessfully.inc();
}

public void setVersion(String version){ nodeInfo.setLabelValues(version.split("/"));}
public void forgedBlock(long millis){
forgeBlockCreationTime.set(millis);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import io.horizen.consensus.ConsensusDataStorage
import io.horizen.evm.LevelDBDatabase
import io.horizen.fork.ForkConfigurator
import io.horizen.helper.{NodeViewProvider, NodeViewProviderImpl, TransactionSubmitProvider, TransactionSubmitProviderImpl}
import io.horizen.metrics.MetricsManager
import io.horizen.network.SyncStatusActorRef
import io.horizen.node.NodeWalletBase
import io.horizen.secret.SecretSerializer
Expand Down Expand Up @@ -196,6 +197,7 @@ class AccountSidechainApp @Inject()
)
override lazy val metricsApiRoute: ApiRoute = if (sidechainSettings.metricsSettings.enabled) route.AccountMetricsRoute(sidechainSettings.metricsSettings, nodeViewHolderRef) else null

MetricsManager.getInstance().setVersion(RpcUtils.getClientVersion(appVersion))

val nodeViewProvider: NodeViewProvider[
TX,
Expand Down

0 comments on commit 3745448

Please sign in to comment.