@@ -46,10 +46,18 @@ var (
46
46
"gnfd-testnet-sp2.nodereal.io" ,
47
47
"gnfd-testnet-sp3.nodereal.io" ,
48
48
}
49
+
50
+ checkBlockMetrics prometheus.Gauge
51
+ checkSpErrCodeMetrics []prometheus.Gauge
49
52
)
50
53
54
+ func initMetrics () {}
55
+
51
56
func CheckDbShard (checkEnv , checkRpc string , checkSpHosts []string ) {
52
- checkBlockMetrics := promauto .NewGauge (prometheus.GaugeOpts {Name : fmt .Sprintf ("%v_sp_db_shard_check_block_height" , checkEnv )})
57
+ if checkBlockMetrics == nil {
58
+ checkBlockMetrics = promauto .NewGauge (prometheus.GaugeOpts {Name : fmt .Sprintf ("%v_sp_db_shard_check_block_height" , checkEnv )})
59
+ }
60
+
53
61
lastChainHeight , err := abci .LastBlockHeight (checkRpc )
54
62
if err != nil {
55
63
checkBlockMetrics .Set (float64 (GetBlockHeightErr ))
@@ -58,14 +66,19 @@ func CheckDbShard(checkEnv, checkRpc string, checkSpHosts []string) {
58
66
calcHeight := lastChainHeight / 3600 * 3600
59
67
checkBlockMetrics .Set (float64 (calcHeight ))
60
68
61
- checkSpErrCodeMetrics := make ([]prometheus.Gauge , len (checkSpHosts ))
69
+ if checkSpErrCodeMetrics == nil {
70
+ checkSpErrCodeMetrics = make ([]prometheus.Gauge , len (checkSpHosts ))
71
+ }
72
+
62
73
objCountArr := make ([][]gjson.Result , len (checkSpHosts ))
63
74
sealObjCountArr := make ([][]gjson.Result , len (checkSpHosts ))
64
75
isErr := false
65
76
for i , spHost := range checkSpHosts {
66
- metricsSpHost := strings .Replace (spHost , "-" , "_" , - 1 )
67
- metricsSpHost = strings .Replace (metricsSpHost , "." , "_" , - 1 )
68
- checkSpErrCodeMetrics [i ] = promauto .NewGauge (prometheus.GaugeOpts {Name : fmt .Sprintf ("%v_sp_db_shard_error_code_%v" , checkEnv , metricsSpHost )})
77
+ if checkSpErrCodeMetrics [i ] == nil {
78
+ metricsSpHost := strings .Replace (spHost , "-" , "_" , - 1 )
79
+ metricsSpHost = strings .Replace (metricsSpHost , "." , "_" , - 1 )
80
+ checkSpErrCodeMetrics [i ] = promauto .NewGauge (prometheus.GaugeOpts {Name : fmt .Sprintf ("%v_sp_db_shard_error_code_%v" , checkEnv , metricsSpHost )})
81
+ }
69
82
70
83
objCount , sealCount , errCode := getSpDbData (spHost , calcHeight )
71
84
if errCode != OK {
0 commit comments