Skip to content

Commit

Permalink
made active stake measure in SOL
Browse files Browse the repository at this point in the history
  • Loading branch information
johnstonematt committed Oct 31, 2024
1 parent 7c56278 commit 9654faa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cmd/solana_exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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...)
}
Expand Down
8 changes: 5 additions & 3 deletions cmd/solana_exporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit 9654faa

Please sign in to comment.