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

feat(metrics): Add custom prometheus port support and log entry #61

Merged
merged 4 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ WEBSOCKET_ENDPOINT="ws://localhost:26657/websocket"
FEEDER_MNEMONIC="guard cream sadness conduct invite crumble clock pudding hole grit liar hotel maid produce squeeze return argue turtle know drive eight casino maze host"
EXCHANGE_SYMBOLS_MAP='{"bitfinex": {"ubtc:unusd": "tBTCUSD", "ueth:unusd": "tETHUSD", "uusd:unusd": "tUSTUSD"}}'
DATASOURCE_CONFIG_MAP='{"coingecko": {"api_key": "0123456789"}}'
VALIDATOR_ADDRESS="nibi1zaavvzxez0elundtn32qnk9lkm8kmcsz44g7xl"
VALIDATOR_ADDRESS="nibi1zaavvzxez0elundtn32qnk9lkm8kmcsz44g7xl"
METRICS_PORT="8080"
11 changes: 9 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,16 @@ var rootCmd = &cobra.Command{

handleInterrupt(logger, f)

metricsPort := os.Getenv("METRICS_PORT")
if metricsPort == "" {
metricsPort = "8080"
}
logger.Info().Msgf("Starting metrics server on port %s", metricsPort)
http.Handle("/metrics", promhttp.Handler())
http.ListenAndServe(":8080", nil)

if err := http.ListenAndServe(":"+metricsPort, nil); err != nil {
logger.Error().Err(err).Msgf("Failed to start metrics server on port %s", metricsPort)
os.Exit(1)
}
select {}
},
}
Expand Down