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
|
||||
VoteKeys []string
|
||||
BalanceAddresses []string
|
||||
Identity string
|
||||
ComprehensiveSlotTracking bool
|
||||
MonitorBlockSizes bool
|
||||
LightMode bool
|
||||
|
@ -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)
|
||||
|
@ -73,11 +72,6 @@ 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,
|
||||
|
@ -85,7 +79,6 @@ func NewExporterConfig(
|
|||
NodeKeys: nodeKeys,
|
||||
VoteKeys: voteKeys,
|
||||
BalanceAddresses: balanceAddresses,
|
||||
Identity: identity,
|
||||
ComprehensiveSlotTracking: comprehensiveSlotTracking,
|
||||
MonitorBlockSizes: monitorBlockSizes,
|
||||
LightMode: lightMode,
|
||||
|
|
|
@ -20,7 +20,6 @@ const (
|
|||
VersionLabel = "version"
|
||||
AddressLabel = "address"
|
||||
EpochLabel = "epoch"
|
||||
IdentityLabel = "identity"
|
||||
TransactionTypeLabel = "transaction_type"
|
||||
|
||||
StatusSkipped = "skipped"
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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.")
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -466,7 +455,6 @@ func newTestConfig(fast bool) *ExporterConfig {
|
|||
identities,
|
||||
votekeys,
|
||||
nil,
|
||||
identity,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
@ -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:")
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
@ -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) {
|
||||
|
|
|
@ -99,10 +99,6 @@ type (
|
|||
Commission uint8 `json:"commission"`
|
||||
}
|
||||
|
||||
Identity struct {
|
||||
Identity string `json:"identity"`
|
||||
}
|
||||
|
||||
FullTransaction struct {
|
||||
Transaction struct {
|
||||
Message struct {
|
||||
|
|
Loading…
Reference in New Issue