From 9654faa7b5cc28943872d3e9665ebc5219f796b6 Mon Sep 17 00:00:00 2001 From: Matt Johnstone Date: Wed, 30 Oct 2024 11:31:53 +0200 Subject: [PATCH] made active stake measure in SOL --- cmd/solana_exporter/exporter.go | 4 ++-- cmd/solana_exporter/exporter_test.go | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/solana_exporter/exporter.go b/cmd/solana_exporter/exporter.go index 12e1906..a5cc070 100644 --- a/cmd/solana_exporter/exporter.go +++ b/cmd/solana_exporter/exporter.go @@ -55,7 +55,7 @@ func NewSolanaCollector(client *rpc.Client, config *ExporterConfig) *SolanaColle config: config, ValidatorActiveStake: NewGaugeDesc( "solana_validator_active_stake", - fmt.Sprintf("Active stake per validator (represented by %s and %s)", VotekeyLabel, NodekeyLabel), + fmt.Sprintf("Active stake (in SOL) per validator (represented by %s and %s)", VotekeyLabel, NodekeyLabel), VotekeyLabel, NodekeyLabel, ), ValidatorLastVote: NewGaugeDesc( @@ -134,7 +134,7 @@ func (c *SolanaCollector) collectVoteAccounts(ctx context.Context, ch chan<- pro for _, account := range append(voteAccounts.Current, voteAccounts.Delinquent...) { accounts := []string{account.VotePubkey, account.NodePubkey} - ch <- c.ValidatorActiveStake.MustNewConstMetric(float64(account.ActivatedStake), accounts...) + ch <- c.ValidatorActiveStake.MustNewConstMetric(float64(account.ActivatedStake)/rpc.LamportsInSol, accounts...) ch <- c.ValidatorLastVote.MustNewConstMetric(float64(account.LastVote), accounts...) ch <- c.ValidatorRootSlot.MustNewConstMetric(float64(account.RootSlot), accounts...) } diff --git a/cmd/solana_exporter/exporter_test.go b/cmd/solana_exporter/exporter_test.go index cade12d..66b2fa5 100644 --- a/cmd/solana_exporter/exporter_test.go +++ b/cmd/solana_exporter/exporter_test.go @@ -210,11 +210,13 @@ func TestSolanaCollector(t *testing.T) { collector := NewSolanaCollector(client, newTestConfig(simulator, false)) prometheus.NewPedanticRegistry().MustRegister(collector) + stake := float64(1_000_000) / rpc.LamportsInSol + testCases := []collectionTest{ collector.ValidatorActiveStake.makeCollectionTest( - NewLV(1_000_000, "aaa", "AAA"), - NewLV(1_000_000, "bbb", "BBB"), - NewLV(1_000_000, "ccc", "CCC"), + NewLV(stake, "aaa", "AAA"), + NewLV(stake, "bbb", "BBB"), + NewLV(stake, "ccc", "CCC"), ), collector.ValidatorLastVote.makeCollectionTest( NewLV(34, "aaa", "AAA"),