@@ -9,7 +9,7 @@ use url::Url;
9
9
10
10
#[ derive( Debug ) ]
11
11
pub enum Report {
12
- Validator ( ( Box < ValidatorReport > , SmolStr , Option < ( usize , u64 , u64 ) > ) ) ,
12
+ Validator ( ( Box < ValidatorReport > , SmolStr , Option < ( usize , u64 ) > ) ) ,
13
13
}
14
14
15
15
#[ derive( Debug ) ]
@@ -22,48 +22,46 @@ pub struct ValidatorMetrics {
22
22
vote_latency : GaugeVec ,
23
23
tvc_rank : IntGaugeVec ,
24
24
steward_rank : IntGaugeVec ,
25
- total_credits : IntGaugeVec ,
26
- epoch_credits : IntGaugeVec ,
25
+ tvc_credits : IntGaugeVec ,
27
26
}
28
27
29
28
impl ValidatorMetrics {
30
29
pub fn new ( registry : & mut Registry ) -> anyhow:: Result < ValidatorMetrics > {
31
- let epoch = IntGaugeVec :: new ( Opts :: new ( "epoch" , "Epoch" ) , & [ "pubkey" , "data_center" ] ) ?;
30
+ let epoch = IntGaugeVec :: new (
31
+ Opts :: new ( "epoch" , "Epoch" ) ,
32
+ & [ "vote_account" , "data_center" ] ,
33
+ ) ?;
32
34
let rank_by_stake = IntGaugeVec :: new (
33
35
Opts :: new ( "rank_by_stake" , "Rank by stake" ) ,
34
- & [ "pubkey " , "data_center" ] ,
36
+ & [ "vote_account " , "data_center" ] ,
35
37
) ?;
36
38
let score = GaugeVec :: new (
37
39
Opts :: new ( "score" , "Steward Score" ) ,
38
- & [ "pubkey " , "data_center" ] ,
40
+ & [ "vote_account " , "data_center" ] ,
39
41
) ?;
40
42
let yield_score = GaugeVec :: new (
41
43
Opts :: new ( "yield_score" , "Yield Score" ) ,
42
- & [ "pubkey " , "data_center" ] ,
44
+ & [ "vote_account " , "data_center" ] ,
43
45
) ?;
44
46
let vote_credits_ratio = GaugeVec :: new (
45
47
Opts :: new ( "vote_credits_ratio" , "Vote credits ratio" ) ,
46
- & [ "pubkey " , "data_center" ] ,
48
+ & [ "vote_account " , "data_center" ] ,
47
49
) ?;
48
50
let vote_latency = GaugeVec :: new (
49
51
Opts :: new ( "vote_latency" , "Vote latency" ) ,
50
- & [ "pubkey " , "data_center" ] ,
52
+ & [ "vote_account " , "data_center" ] ,
51
53
) ?;
52
54
let tvc_rank = IntGaugeVec :: new (
53
55
Opts :: new ( "tvc_rank" , "TVC rank" ) ,
54
- & [ "pubkey " , "data_center" ] ,
56
+ & [ "vote_account " , "data_center" ] ,
55
57
) ?;
56
58
let steward_rank = IntGaugeVec :: new (
57
59
Opts :: new ( "steward_rank" , "Steward Rank" ) ,
58
- & [ "pubkey" , "data_center" ] ,
59
- ) ?;
60
- let total_credits = IntGaugeVec :: new (
61
- Opts :: new ( "total_credits" , "Total Credits" ) ,
62
- & [ "pubkey" , "data_center" ] ,
60
+ & [ "vote_account" , "data_center" ] ,
63
61
) ?;
64
- let epoch_credits = IntGaugeVec :: new (
65
- Opts :: new ( "epoch_credits " , "Epoch Credits " ) ,
66
- & [ "pubkey " , "data_center" ] ,
62
+ let tvc_credits = IntGaugeVec :: new (
63
+ Opts :: new ( "tvc_credits " , "Tvc credits for current epoch " ) ,
64
+ & [ "vote_account " , "data_center" ] ,
67
65
) ?;
68
66
69
67
registry. register ( Box :: new ( epoch. clone ( ) ) ) ?;
@@ -74,8 +72,7 @@ impl ValidatorMetrics {
74
72
registry. register ( Box :: new ( vote_latency. clone ( ) ) ) ?;
75
73
registry. register ( Box :: new ( tvc_rank. clone ( ) ) ) ?;
76
74
registry. register ( Box :: new ( steward_rank. clone ( ) ) ) ?;
77
- registry. register ( Box :: new ( total_credits. clone ( ) ) ) ?;
78
- registry. register ( Box :: new ( epoch_credits. clone ( ) ) ) ?;
75
+ registry. register ( Box :: new ( tvc_credits. clone ( ) ) ) ?;
79
76
80
77
Ok ( ValidatorMetrics {
81
78
epoch,
@@ -86,52 +83,44 @@ impl ValidatorMetrics {
86
83
vote_latency,
87
84
tvc_rank,
88
85
steward_rank,
89
- total_credits,
90
- epoch_credits,
86
+ tvc_credits,
91
87
} )
92
88
}
93
89
94
90
pub fn update_report (
95
91
& self ,
96
- ( report, data_center, tvc_report) : (
97
- Box < ValidatorReport > ,
98
- SmolStr ,
99
- Option < ( usize , u64 , u64 ) > ,
100
- ) ,
92
+ ( report, data_center, tvc_report) : ( Box < ValidatorReport > , SmolStr , Option < ( usize , u64 ) > ) ,
101
93
) {
102
- let pubkey = report. validator_score . vote_account . to_string ( ) ;
103
- let ( tvc_rank, total_credits , epoch_credits ) = tvc_report. unwrap_or_default ( ) ;
94
+ let vote_account = report. validator_score . vote_account . to_string ( ) ;
95
+ let ( tvc_rank, tvc_credits ) = tvc_report. unwrap_or_default ( ) ;
104
96
105
97
self . epoch
106
- . with_label_values ( & [ & pubkey , & data_center] )
98
+ . with_label_values ( & [ & vote_account , & data_center] )
107
99
. set ( report. history_entry . epoch as i64 ) ;
108
100
self . rank_by_stake
109
- . with_label_values ( & [ & pubkey , & data_center] )
101
+ . with_label_values ( & [ & vote_account , & data_center] )
110
102
. set ( report. history_entry . rank as i64 ) ;
111
103
self . score
112
- . with_label_values ( & [ & pubkey , & data_center] )
104
+ . with_label_values ( & [ & vote_account , & data_center] )
113
105
. set ( report. validator_score . score ) ;
114
106
self . yield_score
115
- . with_label_values ( & [ & pubkey , & data_center] )
107
+ . with_label_values ( & [ & vote_account , & data_center] )
116
108
. set ( report. validator_score . yield_score ) ;
117
109
self . vote_credits_ratio
118
- . with_label_values ( & [ & pubkey , & data_center] )
110
+ . with_label_values ( & [ & vote_account , & data_center] )
119
111
. set ( report. validator_score . vote_credits_ratio ) ;
120
112
self . vote_latency
121
- . with_label_values ( & [ & pubkey , & data_center] )
113
+ . with_label_values ( & [ & vote_account , & data_center] )
122
114
. set ( report. vote_latency ) ;
123
115
self . steward_rank
124
- . with_label_values ( & [ & pubkey , & data_center] )
116
+ . with_label_values ( & [ & vote_account , & data_center] )
125
117
. set ( ( report. rank as i64 ) + 1 ) ;
126
118
self . tvc_rank
127
- . with_label_values ( & [ & pubkey , & data_center] )
119
+ . with_label_values ( & [ & vote_account , & data_center] )
128
120
. set ( ( tvc_rank as i64 ) + 1 ) ;
129
- self . total_credits
130
- . with_label_values ( & [ & pubkey, & data_center] )
131
- . set ( total_credits as i64 ) ;
132
- self . epoch_credits
133
- . with_label_values ( & [ & pubkey, & data_center] )
134
- . set ( epoch_credits as i64 ) ;
121
+ self . tvc_credits
122
+ . with_label_values ( & [ & vote_account, & data_center] )
123
+ . set ( tvc_credits as i64 ) ;
135
124
}
136
125
}
137
126
0 commit comments