Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove identity label #64

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 1 addition & 8 deletions cmd/solana_exporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ type (
NodeKeys []string
VoteKeys []string
BalanceAddresses []string
Identity string
ComprehensiveSlotTracking bool
MonitorBlockSizes bool
LightMode bool
Expand Down Expand Up @@ -64,7 +63,7 @@ func NewExporterConfig(
return nil, fmt.Errorf("-light-mode is not compatible with -comprehensiveSlotTracking or -monitorBlockSizes")
}

// get votekeys and identity from rpc:
// get votekeys from rpc:
ctx, cancel := context.WithTimeout(ctx, httpTimeout)
defer cancel()
client := rpc.NewRPCClient(rpcUrl, httpTimeout)
Expand All @@ -73,19 +72,13 @@ func NewExporterConfig(
return nil, fmt.Errorf("error getting vote accounts: %w", err)
}

identity, err := client.GetIdentity(ctx)
if err != nil {
return nil, fmt.Errorf("error getting identity: %w", err)
}

config := ExporterConfig{
HttpTimeout: httpTimeout,
RpcUrl: rpcUrl,
ListenAddress: listenAddress,
NodeKeys: nodeKeys,
VoteKeys: voteKeys,
BalanceAddresses: balanceAddresses,
Identity: identity,
ComprehensiveSlotTracking: comprehensiveSlotTracking,
MonitorBlockSizes: monitorBlockSizes,
LightMode: lightMode,
Expand Down
27 changes: 8 additions & 19 deletions cmd/solana_exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const (
VersionLabel = "version"
AddressLabel = "address"
EpochLabel = "epoch"
IdentityLabel = "identity"
TransactionTypeLabel = "transaction_type"

StatusSkipped = "skipped"
Expand Down Expand Up @@ -102,29 +101,19 @@ func NewSolanaCollector(provider rpc.Provider, config *ExporterConfig) *SolanaCo
),
NodeIsHealthy: NewGaugeDesc(
"solana_node_is_healthy",
fmt.Sprintf("Whether a node (%s) is healthy", IdentityLabel),
IdentityLabel,
"Whether the node is healthy",
),
NodeNumSlotsBehind: NewGaugeDesc(
"solana_node_num_slots_behind",
fmt.Sprintf(
"The number of slots that the node (%s) is behind the latest cluster confirmed slot.",
IdentityLabel,
),
IdentityLabel,
"The number of slots that the node is behind the latest cluster confirmed slot.",
),
NodeMinimumLedgerSlot: NewGaugeDesc(
"solana_node_minimum_ledger_slot",
fmt.Sprintf("The lowest slot that the node (%s) has information about in its ledger.", IdentityLabel),
IdentityLabel,
"The lowest slot that the node has information about in its ledger.",
),
NodeFirstAvailableBlock: NewGaugeDesc(
"solana_node_first_available_block",
fmt.Sprintf(
"The slot of the lowest confirmed block that has not been purged from the node's (%s) ledger.",
IdentityLabel,
),
IdentityLabel,
"The slot of the lowest confirmed block that has not been purged from the node's ledger.",
),
}
return collector
Expand Down Expand Up @@ -202,7 +191,7 @@ func (c *SolanaCollector) collectMinimumLedgerSlot(ctx context.Context, ch chan<
return
}

ch <- c.NodeMinimumLedgerSlot.MustNewConstMetric(float64(*slot), c.config.Identity)
ch <- c.NodeMinimumLedgerSlot.MustNewConstMetric(float64(*slot))
c.logger.Info("Minimum ledger slot collected.")
}
func (c *SolanaCollector) collectFirstAvailableBlock(ctx context.Context, ch chan<- prometheus.Metric) {
Expand All @@ -214,7 +203,7 @@ func (c *SolanaCollector) collectFirstAvailableBlock(ctx context.Context, ch cha
return
}

ch <- c.NodeFirstAvailableBlock.MustNewConstMetric(float64(*block), c.config.Identity)
ch <- c.NodeFirstAvailableBlock.MustNewConstMetric(float64(*block))
c.logger.Info("First available block collected.")
}

Expand Down Expand Up @@ -273,8 +262,8 @@ func (c *SolanaCollector) collectHealth(ctx context.Context, ch chan<- prometheu
}
}

ch <- c.NodeIsHealthy.MustNewConstMetric(float64(isHealthy), c.config.Identity)
ch <- c.NodeNumSlotsBehind.MustNewConstMetric(float64(numSlotsBehind), c.config.Identity)
ch <- c.NodeIsHealthy.MustNewConstMetric(float64(isHealthy))
ch <- c.NodeNumSlotsBehind.MustNewConstMetric(float64(numSlotsBehind))
c.logger.Info("Health collected.")
return
}
Expand Down
24 changes: 6 additions & 18 deletions cmd/solana_exporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type (
var (
identities = []string{"aaa", "bbb", "ccc"}
votekeys = []string{"AAA", "BBB", "CCC"}
identity = "aaa"
balances = map[string]float64{"aaa": 1, "bbb": 2, "ccc": 3, "AAA": 4, "BBB": 5, "CCC": 6}
identityVotes = map[string]string{"aaa": "AAA", "bbb": "BBB", "ccc": "CCC"}
nv = len(identities)
Expand Down Expand Up @@ -185,11 +184,6 @@ func (c *staticRPCClient) GetHealth(ctx context.Context) (*string, error) {
return &health, nil
}

//goland:noinspection GoUnusedParameter
func (c *staticRPCClient) GetIdentity(ctx context.Context) (string, error) {
return identity, nil
}

//goland:noinspection GoUnusedParameter
func (c *staticRPCClient) GetFirstAvailableBlock(ctx context.Context) (*int64, error) {
firstAvailiableBlock := int64(33)
Expand Down Expand Up @@ -403,11 +397,6 @@ func (c *dynamicRPCClient) GetHealth(ctx context.Context) (*string, error) {
return &health, nil
}

//goland:noinspection GoUnusedParameter
func (c *dynamicRPCClient) GetIdentity(ctx context.Context) (string, error) {
return identity, nil
}

//goland:noinspection GoUnusedParameter
func (c *dynamicRPCClient) GetFirstAvailableBlock(ctx context.Context) (*int64, error) {
firstAvailiableBlock := int64(33)
Expand Down Expand Up @@ -466,7 +455,6 @@ func newTestConfig(fast bool) *ExporterConfig {
identities,
votekeys,
nil,
identity,
true,
true,
false,
Expand All @@ -487,8 +475,8 @@ func TestSolanaCollector_Collect_Static(t *testing.T) {
collector.ValidatorDelinquent.makeCollectionTest(abcValues(1, 0, 0)...),
{Name: "solana_account_balance", ExpectedResponse: balanceMetricResponse},
collector.NodeVersion.makeCollectionTest(NewLV(1, "1.16.7")),
collector.NodeIsHealthy.makeCollectionTest(NewLV(1, identity)),
collector.NodeNumSlotsBehind.makeCollectionTest(NewLV(0, identity)),
collector.NodeIsHealthy.makeCollectionTest(NewLV(1)),
collector.NodeNumSlotsBehind.makeCollectionTest(NewLV(0)),
}

runCollectionTests(t, collector, testCases)
Expand All @@ -507,8 +495,8 @@ func TestSolanaCollector_Collect_Dynamic(t *testing.T) {
collector.ValidatorDelinquent.makeCollectionTest(abcValues(0, 0, 0)...),
collector.NodeVersion.makeCollectionTest(NewLV(1, "v1.0.0")),
{Name: "solana_account_balance", ExpectedResponse: balanceMetricResponse},
collector.NodeIsHealthy.makeCollectionTest(NewLV(1, identity)),
collector.NodeNumSlotsBehind.makeCollectionTest(NewLV(0, identity)),
collector.NodeIsHealthy.makeCollectionTest(NewLV(1)),
collector.NodeNumSlotsBehind.makeCollectionTest(NewLV(0)),
}

runCollectionTests(t, collector, testCases)
Expand All @@ -527,8 +515,8 @@ func TestSolanaCollector_Collect_Dynamic(t *testing.T) {
collector.ValidatorDelinquent.makeCollectionTest(abcValues(0, 0, 1)...),
collector.NodeVersion.makeCollectionTest(NewLV(1, "v1.2.3")),
{Name: "solana_account_balance", ExpectedResponse: balanceMetricResponse},
collector.NodeIsHealthy.makeCollectionTest(NewLV(1, identity)),
collector.NodeNumSlotsBehind.makeCollectionTest(NewLV(0, identity)),
collector.NodeIsHealthy.makeCollectionTest(NewLV(1)),
collector.NodeNumSlotsBehind.makeCollectionTest(NewLV(0)),
}

runCollectionTests(t, collector, testCases)
Expand Down
17 changes: 7 additions & 10 deletions cmd/solana_exporter/slots.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type SlotWatcher struct {
InflationRewardsMetric *prometheus.GaugeVec
FeeRewardsMetric *prometheus.CounterVec
BlockSizeMetric *prometheus.GaugeVec
BlockHeightMetric *prometheus.GaugeVec
BlockHeightMetric prometheus.Gauge
}

func NewSlotWatcher(client rpc.Provider, config *ExporterConfig) *SlotWatcher {
Expand Down Expand Up @@ -113,13 +113,10 @@ func NewSlotWatcher(client rpc.Provider, config *ExporterConfig) *SlotWatcher {
},
[]string{NodekeyLabel, TransactionTypeLabel},
),
BlockHeightMetric: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "solana_block_height",
Help: fmt.Sprintf("The current block height of the node, grouped by %s", IdentityLabel),
},
[]string{IdentityLabel},
),
BlockHeightMetric: prometheus.NewGauge(prometheus.GaugeOpts{
Name: "solana_block_height",
Help: "The current block height of the node",
}),
}
// register
logger.Info("Registering slot watcher metrics:")
Expand Down Expand Up @@ -179,7 +176,7 @@ func (c *SlotWatcher) WatchSlots(ctx context.Context) {

c.TotalTransactionsMetric.Set(float64(epochInfo.TransactionCount))
c.SlotHeightMetric.Set(float64(epochInfo.AbsoluteSlot))
c.BlockHeightMetric.WithLabelValues(c.config.Identity).Set(float64(epochInfo.BlockHeight))
c.BlockHeightMetric.Set(float64(epochInfo.BlockHeight))

// if we get here, then the tracking numbers are set, so this is a "normal" run.
// start by checking if we have progressed since last run:
Expand Down Expand Up @@ -404,7 +401,7 @@ func (c *SlotWatcher) fetchAndEmitSingleBlockInfo(
if err != nil {
return err
}
c.BlockHeightMetric.WithLabelValues(nodekey, TransactionTypeVote).Set(float64(voteCount))
c.BlockSizeMetric.WithLabelValues(nodekey, TransactionTypeVote).Set(float64(voteCount))
}

return nil
Expand Down
11 changes: 0 additions & 11 deletions pkg/rpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ type Provider interface {
GetBlock(ctx context.Context, commitment Commitment, slot int64, transactionDetails string) (*Block, error)

GetHealth(ctx context.Context) (*string, error)
GetIdentity(ctx context.Context) (string, error)
GetMinimumLedgerSlot(ctx context.Context) (*int64, error)
GetFirstAvailableBlock(ctx context.Context) (*int64, error)
}
Expand Down Expand Up @@ -322,16 +321,6 @@ func (c *Client) GetHealth(ctx context.Context) (*string, error) {
return &resp.Result, nil
}

// GetIdentity returns the identity pubkey for the current node
// See API docs: https://solana.com/docs/rpc/http/getidentity
func (c *Client) GetIdentity(ctx context.Context) (string, error) {
var resp response[Identity]
if err := getResponse(ctx, c, "getIdentity", []any{}, &resp); err != nil {
return "", err
}
return resp.Result.Identity, nil
}

// GetMinimumLedgerSlot returns the lowest slot that the node has information about in its ledger.
// See API docs: https://solana.com/docs/rpc/http/minimumledgerslot
func (c *Client) GetMinimumLedgerSlot(ctx context.Context) (*int64, error) {
Expand Down
4 changes: 0 additions & 4 deletions pkg/rpc/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,6 @@ type (
Commission uint8 `json:"commission"`
}

Identity struct {
Identity string `json:"identity"`
}

FullTransaction struct {
Transaction struct {
Message struct {
Expand Down
Loading