Skip to content

Commit

Permalink
fix: sei-single didn't include SEI metrics
Browse files Browse the repository at this point in the history
fix: oracle should include validator in label
  • Loading branch information
PFC-developer committed Oct 14, 2023
1 parent 05fae6d commit 4f3fbb5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
4 changes: 2 additions & 2 deletions cmd/kuji-cosmos-exporter/kuji.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func NewKujiMetrics(reg prometheus.Registerer, config *exporter.ServiceConfig) *
Help: "Vote miss count",
ConstLabels: config.ConstLabels,
},
[]string{"type"},
[]string{"type", "validator"},
),
}

Expand Down Expand Up @@ -65,7 +65,7 @@ func getKujiMetrics(wg *sync.WaitGroup, sublogger *zerolog.Logger, metrics *Kuji

missCount := float64(response.MissCounter)

metrics.votePenaltyCount.WithLabelValues("miss").Add(missCount)
metrics.votePenaltyCount.WithLabelValues("miss", validatorAddress.String()).Add(missCount)

}()
}
Expand Down
22 changes: 12 additions & 10 deletions cmd/sei-cosmos-exporter/sei.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ import (
oracletypes "github.com/sei-protocol/sei-chain/x/oracle/types"
)

type votePenaltyCounter struct {
MissCount string `json:"miss_count"`
AbstainCount string `json:"abstain_count"`
SuccessCount string `json:"success_count"`
}
/*
type votePenaltyCounter struct {
MissCount string `json:"miss_count"`
AbstainCount string `json:"abstain_count"`
SuccessCount string `json:"success_count"`
}
*/
type SeiMetrics struct {
votePenaltyCount *prometheus.CounterVec
}
Expand All @@ -29,11 +31,11 @@ func NewSeiMetrics(reg prometheus.Registerer, config *exporter.ServiceConfig) *S
m := &SeiMetrics{
votePenaltyCount: prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "cosmos_oracle_vote_penalty_count",
Name: "cosmos_sei_oracle_vote_penalty_count",
Help: "Vote penalty miss count",
ConstLabels: config.ConstLabels,
},
[]string{"type"},
[]string{"type", "validator"},
),
}

Expand Down Expand Up @@ -67,9 +69,9 @@ func getSeiMetrics(wg *sync.WaitGroup, sublogger *zerolog.Logger, metrics *SeiMe
abstainCount := float64(response.VotePenaltyCounter.AbstainCount)
successCount := float64(response.VotePenaltyCounter.SuccessCount)

metrics.votePenaltyCount.WithLabelValues("miss").Add(missCount)
metrics.votePenaltyCount.WithLabelValues("abstain").Add(abstainCount)
metrics.votePenaltyCount.WithLabelValues("success").Add(successCount)
metrics.votePenaltyCount.WithLabelValues("miss", validatorAddress.String()).Add(missCount)
metrics.votePenaltyCount.WithLabelValues("abstain", validatorAddress.String()).Add(abstainCount)
metrics.votePenaltyCount.WithLabelValues("success", validatorAddress.String()).Add(successCount)

}()

Expand Down
10 changes: 7 additions & 3 deletions cmd/sei-cosmos-exporter/single.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func SeiSingleHandler(w http.ResponseWriter, r *http.Request, s *exporter.Servic
var paramsMetrics *exporter.ParamsMetrics
var upgradeMetrics *exporter.UpgradeMetrics
var walletMetrics *exporter.WalletMetrics
var seiMetrics *SeiMetrics

var proposalMetrics *exporter.ProposalsMetrics

Expand All @@ -42,6 +43,9 @@ func SeiSingleHandler(w http.ResponseWriter, r *http.Request, s *exporter.Servic
if s.Proposals {
proposalMetrics = exporter.NewProposalsMetrics(registry, s.Config)
}
if s.Oracle {
seiMetrics = NewSeiMetrics(registry, s.Config)
}

var wg sync.WaitGroup

Expand Down Expand Up @@ -77,9 +81,8 @@ func SeiSingleHandler(w http.ResponseWriter, r *http.Request, s *exporter.Servic
}()

if s.Oracle {
sublogger.Debug().Str("address", validator).Msg("Fetching Kujira details")

// getKujiMetrics(&wg, &sublogger, kujiOracleMetrics, s, s.Config, valAddress)
sublogger.Debug().Str("address", validator).Msg("Fetching SEI details")
getSeiMetrics(&wg, &sublogger, seiMetrics, s, s.Config, valAddress)
}
}
}
Expand All @@ -101,6 +104,7 @@ func SeiSingleHandler(w http.ResponseWriter, r *http.Request, s *exporter.Servic
if s.Proposals {
exporter.GetProposalsMetrics(&wg, &sublogger, proposalMetrics, s, s.Config, true)
}

wg.Wait()

h := promhttp.HandlerFor(registry, promhttp.HandlerOpts{})
Expand Down

0 comments on commit 4f3fbb5

Please sign in to comment.