Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: timeouts #20

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions cmd/warden-exporter/warden-exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,29 @@ func main() {
Cfg: cfg,
}

prometheus.MustRegister(wardenCollector)
prometheus.MustRegister(intentCollector)
prometheus.MustRegister(authCollector)
prometheus.MustRegister(walletCollector)
go prometheus.MustRegister(wardenCollector)
go prometheus.MustRegister(intentCollector)
go prometheus.MustRegister(authCollector)
go prometheus.MustRegister(walletCollector)
}

if cfg.ValidatorMetrics {
validatorCollector := collector.ValidatorsCollector{
Cfg: cfg,
}
prometheus.MustRegister(validatorCollector)
go prometheus.MustRegister(validatorCollector)
}

if cfg.WarpMetrics {
warpCollector := collector.WarpCollector{
Cfg: cfg,
}
prometheus.MustRegister(warpCollector)
go prometheus.MustRegister(warpCollector)
}

mux := http.NewServeMux()
mux.Handle("/metrics", promhttp.Handler())
mux.HandleFunc("/healthz", healthCheckHandler)

addr := fmt.Sprintf(":%d", *port)

Expand All @@ -84,3 +85,11 @@ func main() {
log.Fatal(err.Error())
}
}

// healthCheckHandler handles the /healthz endpoint.
func healthCheckHandler(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
if _, err := w.Write([]byte("OK")); err != nil {
log.Error(err.Error())
}
}
4 changes: 3 additions & 1 deletion pkg/collector/warden_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ func (w WardenCollector) Describe(ch chan<- *prometheus.Desc) {
ch <- pendingKeys
ch <- keychains
ch <- keychainRequests
ch <- keychain
ch <- keychainSignatureRequests
}

func (w WardenCollector) Collect(ch chan<- prometheus.Metric) {
Expand Down Expand Up @@ -289,5 +291,5 @@ func (w WardenCollector) Collect(ch chan<- prometheus.Metric) {
)
}

log.Debug("Stop collecting", zap.String("metric", spacesMetricName))
log.Info("Stop collecting", zap.String("metric", spacesMetricName))
}
2 changes: 2 additions & 0 deletions pkg/collector/warp_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

_ "github.com/go-sql-driver/mysql" // mysql driver
"github.com/prometheus/client_golang/prometheus"
"go.uber.org/zap"

"github.com/warden-protocol/warden-exporter/pkg/config"
log "github.com/warden-protocol/warden-exporter/pkg/logger"
Expand Down Expand Up @@ -114,6 +115,7 @@ func (w WarpCollector) Collect(ch chan<- prometheus.Metric) {
}...,
)
}
log.Info("Stop collecting", zap.String("metric", "warp"))
}

func queryWarpUsers(db *sql.DB) (int, error) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ func configError(msg string) error {
type Config struct {
Addr string `env:"GRPC_ADDR" envDefault:"grpc.buenavista.wardenprotocol.org:443"`
TLS bool `env:"GRPC_TLS_ENABLED" envDefault:"true"`
Timeout int `env:"GRPC_TIMEOUT_SECONDS" envDefault:"15"`
TTL int `env:"TTL" envDefault:"30"`
Timeout int `env:"GRPC_TIMEOUT_SECONDS" envDefault:"45"`
TTL int `env:"TTL" envDefault:"60"`
ChainID string `env:"CHAIN_ID" envDefault:"buenavista-1"`
WardenMetrics bool `env:"WARDEN_METRICS" envDefault:"true"`
ValidatorMetrics bool `env:"VALIDATOR_METRICS" envDefault:"true"`
Expand Down
Loading