standardised on counter names ending in _total
This commit is contained in:
parent
9542fc1588
commit
ef6941e87b
|
@ -39,7 +39,7 @@ type SlotWatcher struct {
|
|||
EpochLastSlotMetric prometheus.Gauge
|
||||
LeaderSlotsMetric *prometheus.CounterVec
|
||||
LeaderSlotsByEpochMetric *prometheus.CounterVec
|
||||
InflationRewardsMetric *prometheus.GaugeVec
|
||||
InflationRewardsMetric *prometheus.CounterVec
|
||||
FeeRewardsMetric *prometheus.CounterVec
|
||||
BlockSizeMetric *prometheus.GaugeVec
|
||||
BlockHeightMetric prometheus.Gauge
|
||||
|
@ -74,7 +74,7 @@ func NewSlotWatcher(client *rpc.Client, config *ExporterConfig) *SlotWatcher {
|
|||
}),
|
||||
LeaderSlotsMetric: prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "solana_validator_leader_slots",
|
||||
Name: "solana_validator_leader_slots_total",
|
||||
Help: fmt.Sprintf(
|
||||
"Number of slots processed, grouped by %s, and %s ('%s' or '%s')",
|
||||
NodekeyLabel, SkipStatusLabel, StatusValid, StatusSkipped,
|
||||
|
@ -84,7 +84,7 @@ func NewSlotWatcher(client *rpc.Client, config *ExporterConfig) *SlotWatcher {
|
|||
),
|
||||
LeaderSlotsByEpochMetric: prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "solana_validator_leader_slots_by_epoch",
|
||||
Name: "solana_validator_leader_slots_by_epoch_total",
|
||||
Help: fmt.Sprintf(
|
||||
"Number of slots processed, grouped by %s, %s ('%s' or '%s'), and %s",
|
||||
NodekeyLabel, SkipStatusLabel, StatusValid, StatusSkipped, EpochLabel,
|
||||
|
@ -92,16 +92,16 @@ func NewSlotWatcher(client *rpc.Client, config *ExporterConfig) *SlotWatcher {
|
|||
},
|
||||
[]string{NodekeyLabel, EpochLabel, SkipStatusLabel},
|
||||
),
|
||||
InflationRewardsMetric: prometheus.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "solana_validator_inflation_rewards",
|
||||
InflationRewardsMetric: prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "solana_validator_inflation_rewards_total",
|
||||
Help: fmt.Sprintf("Inflation reward earned, grouped by %s and %s", VotekeyLabel, EpochLabel),
|
||||
},
|
||||
[]string{VotekeyLabel, EpochLabel},
|
||||
),
|
||||
FeeRewardsMetric: prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "solana_validator_fee_rewards",
|
||||
Name: "solana_validator_fee_rewards_total",
|
||||
Help: fmt.Sprintf("Transaction fee rewards earned, grouped by %s and %s", NodekeyLabel, EpochLabel),
|
||||
},
|
||||
[]string{NodekeyLabel, EpochLabel},
|
||||
|
@ -423,7 +423,7 @@ func (c *SlotWatcher) fetchAndEmitInflationRewards(ctx context.Context, epoch in
|
|||
for i, rewardInfo := range rewardInfos {
|
||||
address := c.config.VoteKeys[i]
|
||||
reward := float64(rewardInfo.Amount) / float64(rpc.LamportsInSol)
|
||||
c.InflationRewardsMetric.WithLabelValues(address, toString(epoch)).Set(reward)
|
||||
c.InflationRewardsMetric.WithLabelValues(address, toString(epoch)).Add(reward)
|
||||
}
|
||||
c.logger.Infof("Fetched inflation reward for epoch %v.", epoch)
|
||||
return nil
|
||||
|
|
|
@ -109,38 +109,38 @@ func TestSlotWatcher_WatchSlots_Static(t *testing.T) {
|
|||
time.Sleep(1 * time.Second)
|
||||
|
||||
type testCase struct {
|
||||
name string
|
||||
expectedValue float64
|
||||
metric prometheus.Gauge
|
||||
metric prometheus.Collector
|
||||
}
|
||||
|
||||
// epoch info tests:
|
||||
firstSlot, lastSlot := GetEpochBounds(epochInfo)
|
||||
tests := []testCase{
|
||||
{expectedValue: float64(epochInfo.AbsoluteSlot), metric: watcher.SlotHeightMetric},
|
||||
{expectedValue: float64(epochInfo.TransactionCount), metric: watcher.TotalTransactionsMetric},
|
||||
{expectedValue: float64(epochInfo.Epoch), metric: watcher.EpochNumberMetric},
|
||||
{expectedValue: float64(firstSlot), metric: watcher.EpochFirstSlotMetric},
|
||||
{expectedValue: float64(lastSlot), metric: watcher.EpochLastSlotMetric},
|
||||
{"slot_height", float64(epochInfo.AbsoluteSlot), watcher.SlotHeightMetric},
|
||||
{"total_transactions", float64(epochInfo.TransactionCount), watcher.TotalTransactionsMetric},
|
||||
{"epoch_number", float64(epochInfo.Epoch), watcher.EpochNumberMetric},
|
||||
{"epoch_first_slot", float64(firstSlot), watcher.EpochFirstSlotMetric},
|
||||
{"epoch_last_slot", float64(lastSlot), watcher.EpochLastSlotMetric},
|
||||
}
|
||||
|
||||
// add inflation reward tests:
|
||||
inflationRewards, err := client.GetInflationReward(ctx, rpc.CommitmentFinalized, simulator.Votekeys, 2)
|
||||
assert.NoError(t, err)
|
||||
for i, rewardInfo := range inflationRewards {
|
||||
epoch := fmt.Sprintf("%v", epochInfo.Epoch)
|
||||
tests = append(
|
||||
tests,
|
||||
testCase{
|
||||
expectedValue: float64(rewardInfo.Amount) / float64(rpc.LamportsInSol),
|
||||
metric: watcher.InflationRewardsMetric.WithLabelValues(simulator.Votekeys[i], epoch),
|
||||
fmt.Sprintf("inflation_rewards_%s", simulator.Votekeys[i]),
|
||||
float64(rewardInfo.Amount) / float64(rpc.LamportsInSol),
|
||||
watcher.InflationRewardsMetric.WithLabelValues(simulator.Votekeys[i], toString(epochInfo.Epoch)),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
for _, testCase := range tests {
|
||||
name := extractName(testCase.metric.Desc())
|
||||
t.Run(name, func(t *testing.T) {
|
||||
assert.Equal(t, testCase.expectedValue, testutil.ToFloat64(testCase.metric))
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
assert.Equal(t, test.expectedValue, testutil.ToFloat64(test.metric))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue