Merge pull request #64 from asymmetric-research/remove-identity
Remove identity label
This commit is contained in:
commit
cbdf5065a6
|
@ -19,7 +19,6 @@ type (
|
||||||
NodeKeys []string
|
NodeKeys []string
|
||||||
VoteKeys []string
|
VoteKeys []string
|
||||||
BalanceAddresses []string
|
BalanceAddresses []string
|
||||||
Identity string
|
|
||||||
ComprehensiveSlotTracking bool
|
ComprehensiveSlotTracking bool
|
||||||
MonitorBlockSizes bool
|
MonitorBlockSizes bool
|
||||||
LightMode bool
|
LightMode bool
|
||||||
|
@ -64,7 +63,7 @@ func NewExporterConfig(
|
||||||
return nil, fmt.Errorf("-light-mode is not compatible with -comprehensiveSlotTracking or -monitorBlockSizes")
|
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)
|
ctx, cancel := context.WithTimeout(ctx, httpTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
client := rpc.NewRPCClient(rpcUrl, httpTimeout)
|
client := rpc.NewRPCClient(rpcUrl, httpTimeout)
|
||||||
|
@ -73,11 +72,6 @@ func NewExporterConfig(
|
||||||
return nil, fmt.Errorf("error getting vote accounts: %w", err)
|
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{
|
config := ExporterConfig{
|
||||||
HttpTimeout: httpTimeout,
|
HttpTimeout: httpTimeout,
|
||||||
RpcUrl: rpcUrl,
|
RpcUrl: rpcUrl,
|
||||||
|
@ -85,7 +79,6 @@ func NewExporterConfig(
|
||||||
NodeKeys: nodeKeys,
|
NodeKeys: nodeKeys,
|
||||||
VoteKeys: voteKeys,
|
VoteKeys: voteKeys,
|
||||||
BalanceAddresses: balanceAddresses,
|
BalanceAddresses: balanceAddresses,
|
||||||
Identity: identity,
|
|
||||||
ComprehensiveSlotTracking: comprehensiveSlotTracking,
|
ComprehensiveSlotTracking: comprehensiveSlotTracking,
|
||||||
MonitorBlockSizes: monitorBlockSizes,
|
MonitorBlockSizes: monitorBlockSizes,
|
||||||
LightMode: lightMode,
|
LightMode: lightMode,
|
||||||
|
|
|
@ -20,7 +20,6 @@ const (
|
||||||
VersionLabel = "version"
|
VersionLabel = "version"
|
||||||
AddressLabel = "address"
|
AddressLabel = "address"
|
||||||
EpochLabel = "epoch"
|
EpochLabel = "epoch"
|
||||||
IdentityLabel = "identity"
|
|
||||||
TransactionTypeLabel = "transaction_type"
|
TransactionTypeLabel = "transaction_type"
|
||||||
|
|
||||||
StatusSkipped = "skipped"
|
StatusSkipped = "skipped"
|
||||||
|
@ -102,29 +101,19 @@ func NewSolanaCollector(provider rpc.Provider, config *ExporterConfig) *SolanaCo
|
||||||
),
|
),
|
||||||
NodeIsHealthy: NewGaugeDesc(
|
NodeIsHealthy: NewGaugeDesc(
|
||||||
"solana_node_is_healthy",
|
"solana_node_is_healthy",
|
||||||
fmt.Sprintf("Whether a node (%s) is healthy", IdentityLabel),
|
"Whether the node is healthy",
|
||||||
IdentityLabel,
|
|
||||||
),
|
),
|
||||||
NodeNumSlotsBehind: NewGaugeDesc(
|
NodeNumSlotsBehind: NewGaugeDesc(
|
||||||
"solana_node_num_slots_behind",
|
"solana_node_num_slots_behind",
|
||||||
fmt.Sprintf(
|
"The number of slots that the node is behind the latest cluster confirmed slot.",
|
||||||
"The number of slots that the node (%s) is behind the latest cluster confirmed slot.",
|
|
||||||
IdentityLabel,
|
|
||||||
),
|
|
||||||
IdentityLabel,
|
|
||||||
),
|
),
|
||||||
NodeMinimumLedgerSlot: NewGaugeDesc(
|
NodeMinimumLedgerSlot: NewGaugeDesc(
|
||||||
"solana_node_minimum_ledger_slot",
|
"solana_node_minimum_ledger_slot",
|
||||||
fmt.Sprintf("The lowest slot that the node (%s) has information about in its ledger.", IdentityLabel),
|
"The lowest slot that the node has information about in its ledger.",
|
||||||
IdentityLabel,
|
|
||||||
),
|
),
|
||||||
NodeFirstAvailableBlock: NewGaugeDesc(
|
NodeFirstAvailableBlock: NewGaugeDesc(
|
||||||
"solana_node_first_available_block",
|
"solana_node_first_available_block",
|
||||||
fmt.Sprintf(
|
"The slot of the lowest confirmed block that has not been purged from the node's ledger.",
|
||||||
"The slot of the lowest confirmed block that has not been purged from the node's (%s) ledger.",
|
|
||||||
IdentityLabel,
|
|
||||||
),
|
|
||||||
IdentityLabel,
|
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
return collector
|
return collector
|
||||||
|
@ -202,7 +191,7 @@ func (c *SolanaCollector) collectMinimumLedgerSlot(ctx context.Context, ch chan<
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ch <- c.NodeMinimumLedgerSlot.MustNewConstMetric(float64(*slot), c.config.Identity)
|
ch <- c.NodeMinimumLedgerSlot.MustNewConstMetric(float64(*slot))
|
||||||
c.logger.Info("Minimum ledger slot collected.")
|
c.logger.Info("Minimum ledger slot collected.")
|
||||||
}
|
}
|
||||||
func (c *SolanaCollector) collectFirstAvailableBlock(ctx context.Context, ch chan<- prometheus.Metric) {
|
func (c *SolanaCollector) collectFirstAvailableBlock(ctx context.Context, ch chan<- prometheus.Metric) {
|
||||||
|
@ -214,7 +203,7 @@ func (c *SolanaCollector) collectFirstAvailableBlock(ctx context.Context, ch cha
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ch <- c.NodeFirstAvailableBlock.MustNewConstMetric(float64(*block), c.config.Identity)
|
ch <- c.NodeFirstAvailableBlock.MustNewConstMetric(float64(*block))
|
||||||
c.logger.Info("First available block collected.")
|
c.logger.Info("First available block collected.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.NodeIsHealthy.MustNewConstMetric(float64(isHealthy))
|
||||||
ch <- c.NodeNumSlotsBehind.MustNewConstMetric(float64(numSlotsBehind), c.config.Identity)
|
ch <- c.NodeNumSlotsBehind.MustNewConstMetric(float64(numSlotsBehind))
|
||||||
c.logger.Info("Health collected.")
|
c.logger.Info("Health collected.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@ type (
|
||||||
var (
|
var (
|
||||||
identities = []string{"aaa", "bbb", "ccc"}
|
identities = []string{"aaa", "bbb", "ccc"}
|
||||||
votekeys = []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}
|
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"}
|
identityVotes = map[string]string{"aaa": "AAA", "bbb": "BBB", "ccc": "CCC"}
|
||||||
nv = len(identities)
|
nv = len(identities)
|
||||||
|
@ -185,11 +184,6 @@ func (c *staticRPCClient) GetHealth(ctx context.Context) (*string, error) {
|
||||||
return &health, nil
|
return &health, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//goland:noinspection GoUnusedParameter
|
|
||||||
func (c *staticRPCClient) GetIdentity(ctx context.Context) (string, error) {
|
|
||||||
return identity, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
//goland:noinspection GoUnusedParameter
|
//goland:noinspection GoUnusedParameter
|
||||||
func (c *staticRPCClient) GetFirstAvailableBlock(ctx context.Context) (*int64, error) {
|
func (c *staticRPCClient) GetFirstAvailableBlock(ctx context.Context) (*int64, error) {
|
||||||
firstAvailiableBlock := int64(33)
|
firstAvailiableBlock := int64(33)
|
||||||
|
@ -403,11 +397,6 @@ func (c *dynamicRPCClient) GetHealth(ctx context.Context) (*string, error) {
|
||||||
return &health, nil
|
return &health, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//goland:noinspection GoUnusedParameter
|
|
||||||
func (c *dynamicRPCClient) GetIdentity(ctx context.Context) (string, error) {
|
|
||||||
return identity, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
//goland:noinspection GoUnusedParameter
|
//goland:noinspection GoUnusedParameter
|
||||||
func (c *dynamicRPCClient) GetFirstAvailableBlock(ctx context.Context) (*int64, error) {
|
func (c *dynamicRPCClient) GetFirstAvailableBlock(ctx context.Context) (*int64, error) {
|
||||||
firstAvailiableBlock := int64(33)
|
firstAvailiableBlock := int64(33)
|
||||||
|
@ -466,7 +455,6 @@ func newTestConfig(fast bool) *ExporterConfig {
|
||||||
identities,
|
identities,
|
||||||
votekeys,
|
votekeys,
|
||||||
nil,
|
nil,
|
||||||
identity,
|
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
|
@ -487,8 +475,8 @@ func TestSolanaCollector_Collect_Static(t *testing.T) {
|
||||||
collector.ValidatorDelinquent.makeCollectionTest(abcValues(1, 0, 0)...),
|
collector.ValidatorDelinquent.makeCollectionTest(abcValues(1, 0, 0)...),
|
||||||
{Name: "solana_account_balance", ExpectedResponse: balanceMetricResponse},
|
{Name: "solana_account_balance", ExpectedResponse: balanceMetricResponse},
|
||||||
collector.NodeVersion.makeCollectionTest(NewLV(1, "1.16.7")),
|
collector.NodeVersion.makeCollectionTest(NewLV(1, "1.16.7")),
|
||||||
collector.NodeIsHealthy.makeCollectionTest(NewLV(1, identity)),
|
collector.NodeIsHealthy.makeCollectionTest(NewLV(1)),
|
||||||
collector.NodeNumSlotsBehind.makeCollectionTest(NewLV(0, identity)),
|
collector.NodeNumSlotsBehind.makeCollectionTest(NewLV(0)),
|
||||||
}
|
}
|
||||||
|
|
||||||
runCollectionTests(t, collector, testCases)
|
runCollectionTests(t, collector, testCases)
|
||||||
|
@ -507,8 +495,8 @@ func TestSolanaCollector_Collect_Dynamic(t *testing.T) {
|
||||||
collector.ValidatorDelinquent.makeCollectionTest(abcValues(0, 0, 0)...),
|
collector.ValidatorDelinquent.makeCollectionTest(abcValues(0, 0, 0)...),
|
||||||
collector.NodeVersion.makeCollectionTest(NewLV(1, "v1.0.0")),
|
collector.NodeVersion.makeCollectionTest(NewLV(1, "v1.0.0")),
|
||||||
{Name: "solana_account_balance", ExpectedResponse: balanceMetricResponse},
|
{Name: "solana_account_balance", ExpectedResponse: balanceMetricResponse},
|
||||||
collector.NodeIsHealthy.makeCollectionTest(NewLV(1, identity)),
|
collector.NodeIsHealthy.makeCollectionTest(NewLV(1)),
|
||||||
collector.NodeNumSlotsBehind.makeCollectionTest(NewLV(0, identity)),
|
collector.NodeNumSlotsBehind.makeCollectionTest(NewLV(0)),
|
||||||
}
|
}
|
||||||
|
|
||||||
runCollectionTests(t, collector, testCases)
|
runCollectionTests(t, collector, testCases)
|
||||||
|
@ -527,8 +515,8 @@ func TestSolanaCollector_Collect_Dynamic(t *testing.T) {
|
||||||
collector.ValidatorDelinquent.makeCollectionTest(abcValues(0, 0, 1)...),
|
collector.ValidatorDelinquent.makeCollectionTest(abcValues(0, 0, 1)...),
|
||||||
collector.NodeVersion.makeCollectionTest(NewLV(1, "v1.2.3")),
|
collector.NodeVersion.makeCollectionTest(NewLV(1, "v1.2.3")),
|
||||||
{Name: "solana_account_balance", ExpectedResponse: balanceMetricResponse},
|
{Name: "solana_account_balance", ExpectedResponse: balanceMetricResponse},
|
||||||
collector.NodeIsHealthy.makeCollectionTest(NewLV(1, identity)),
|
collector.NodeIsHealthy.makeCollectionTest(NewLV(1)),
|
||||||
collector.NodeNumSlotsBehind.makeCollectionTest(NewLV(0, identity)),
|
collector.NodeNumSlotsBehind.makeCollectionTest(NewLV(0)),
|
||||||
}
|
}
|
||||||
|
|
||||||
runCollectionTests(t, collector, testCases)
|
runCollectionTests(t, collector, testCases)
|
||||||
|
|
|
@ -42,7 +42,7 @@ type SlotWatcher struct {
|
||||||
InflationRewardsMetric *prometheus.GaugeVec
|
InflationRewardsMetric *prometheus.GaugeVec
|
||||||
FeeRewardsMetric *prometheus.CounterVec
|
FeeRewardsMetric *prometheus.CounterVec
|
||||||
BlockSizeMetric *prometheus.GaugeVec
|
BlockSizeMetric *prometheus.GaugeVec
|
||||||
BlockHeightMetric *prometheus.GaugeVec
|
BlockHeightMetric prometheus.Gauge
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSlotWatcher(client rpc.Provider, config *ExporterConfig) *SlotWatcher {
|
func NewSlotWatcher(client rpc.Provider, config *ExporterConfig) *SlotWatcher {
|
||||||
|
@ -113,13 +113,10 @@ func NewSlotWatcher(client rpc.Provider, config *ExporterConfig) *SlotWatcher {
|
||||||
},
|
},
|
||||||
[]string{NodekeyLabel, TransactionTypeLabel},
|
[]string{NodekeyLabel, TransactionTypeLabel},
|
||||||
),
|
),
|
||||||
BlockHeightMetric: prometheus.NewGaugeVec(
|
BlockHeightMetric: prometheus.NewGauge(prometheus.GaugeOpts{
|
||||||
prometheus.GaugeOpts{
|
Name: "solana_block_height",
|
||||||
Name: "solana_block_height",
|
Help: "The current block height of the node",
|
||||||
Help: fmt.Sprintf("The current block height of the node, grouped by %s", IdentityLabel),
|
}),
|
||||||
},
|
|
||||||
[]string{IdentityLabel},
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
// register
|
// register
|
||||||
logger.Info("Registering slot watcher metrics:")
|
logger.Info("Registering slot watcher metrics:")
|
||||||
|
@ -179,7 +176,7 @@ func (c *SlotWatcher) WatchSlots(ctx context.Context) {
|
||||||
|
|
||||||
c.TotalTransactionsMetric.Set(float64(epochInfo.TransactionCount))
|
c.TotalTransactionsMetric.Set(float64(epochInfo.TransactionCount))
|
||||||
c.SlotHeightMetric.Set(float64(epochInfo.AbsoluteSlot))
|
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.
|
// 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:
|
// start by checking if we have progressed since last run:
|
||||||
|
@ -404,7 +401,7 @@ func (c *SlotWatcher) fetchAndEmitSingleBlockInfo(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
c.BlockHeightMetric.WithLabelValues(nodekey, TransactionTypeVote).Set(float64(voteCount))
|
c.BlockSizeMetric.WithLabelValues(nodekey, TransactionTypeVote).Set(float64(voteCount))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -77,7 +77,6 @@ type Provider interface {
|
||||||
GetBlock(ctx context.Context, commitment Commitment, slot int64, transactionDetails string) (*Block, error)
|
GetBlock(ctx context.Context, commitment Commitment, slot int64, transactionDetails string) (*Block, error)
|
||||||
|
|
||||||
GetHealth(ctx context.Context) (*string, error)
|
GetHealth(ctx context.Context) (*string, error)
|
||||||
GetIdentity(ctx context.Context) (string, error)
|
|
||||||
GetMinimumLedgerSlot(ctx context.Context) (*int64, error)
|
GetMinimumLedgerSlot(ctx context.Context) (*int64, error)
|
||||||
GetFirstAvailableBlock(ctx context.Context) (*int64, error)
|
GetFirstAvailableBlock(ctx context.Context) (*int64, error)
|
||||||
}
|
}
|
||||||
|
@ -322,16 +321,6 @@ func (c *Client) GetHealth(ctx context.Context) (*string, error) {
|
||||||
return &resp.Result, nil
|
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.
|
// GetMinimumLedgerSlot returns the lowest slot that the node has information about in its ledger.
|
||||||
// See API docs: https://solana.com/docs/rpc/http/minimumledgerslot
|
// See API docs: https://solana.com/docs/rpc/http/minimumledgerslot
|
||||||
func (c *Client) GetMinimumLedgerSlot(ctx context.Context) (*int64, error) {
|
func (c *Client) GetMinimumLedgerSlot(ctx context.Context) (*int64, error) {
|
||||||
|
|
|
@ -99,10 +99,6 @@ type (
|
||||||
Commission uint8 `json:"commission"`
|
Commission uint8 `json:"commission"`
|
||||||
}
|
}
|
||||||
|
|
||||||
Identity struct {
|
|
||||||
Identity string `json:"identity"`
|
|
||||||
}
|
|
||||||
|
|
||||||
FullTransaction struct {
|
FullTransaction struct {
|
||||||
Transaction struct {
|
Transaction struct {
|
||||||
Message struct {
|
Message struct {
|
||||||
|
|
Loading…
Reference in New Issue