diff --git a/README.md b/README.md index ba0c913..401bcbd 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,7 @@ You can pass the arguments to the executable file to configure it. Here is the p - `--log-devel` - logger level. Defaults to `info`. You can set it to `debug` to make it more verbose. - `--limit` - pagination limit for gRPC requests. Defaults to 1000. - `--json` - output logs as JSON. Useful if you don't read it on servers but instead use logging aggregation solutions such as ELK stack. +- `--price` - fetch token price (defaults to true) You can also specify custom Bech32 prefixes for wallets, validators, consensus nodes, and their pubkeys by using the following params: diff --git a/general.go b/general.go index 832bc9f..e18f590 100644 --- a/general.go +++ b/general.go @@ -119,18 +119,20 @@ func NewGeneralMetrics(reg prometheus.Registerer) *GeneralMetrics { } func getGeneralMetrics(wg *sync.WaitGroup, sublogger *zerolog.Logger, metrics *GeneralMetrics, s *service) { - wg.Add(1) - go func() { - defer wg.Done() - chain, err := cosmosdirectory.GetChainByChainID(ChainID) - if err != nil { - sublogger.Error().Err(err).Msg("Could not get chain information") - return - } + if TokenPrice { + wg.Add(1) + go func() { + defer wg.Done() + chain, err := cosmosdirectory.GetChainByChainID(ChainID) + if err != nil { + sublogger.Error().Err(err).Msg("Could not get chain information") + return + } - price := chain.GetPriceUSD() - metrics.tokenPrice.Set(price) - }() + price := chain.GetPriceUSD() + metrics.tokenPrice.Set(price) + }() + } wg.Add(1) go func() { diff --git a/main.go b/main.go index f49143b..b23c976 100644 --- a/main.go +++ b/main.go @@ -50,6 +50,7 @@ var ( Upgrades bool Proposals bool Params bool + TokenPrice bool ) type service struct { @@ -207,6 +208,7 @@ func Execute(_ *cobra.Command, _ []string) { Str("--proposals", fmt.Sprintf("%t", Proposals)). Str("--params", fmt.Sprintf("%t", Params)). Str("--upgrades", fmt.Sprintf("%t", Upgrades)). + Str("--price", fmt.Sprintf("%t", TokenPrice)). Msg("Started with following parameters") config := sdk.GetConfig() @@ -381,6 +383,7 @@ func main() { rootCmd.PersistentFlags().BoolVar(&Upgrades, "upgrades", false, "serve upgrade info in the single call to /metrics") rootCmd.PersistentFlags().BoolVar(&Proposals, "proposals", false, "serve active proposal info in the single call to /metrics") rootCmd.PersistentFlags().BoolVar(&Params, "params", false, "serve chain params info in the single call to /metrics") + rootCmd.PersistentFlags().BoolVar(&TokenPrice, "price", true, "fetch token price") rootCmd.PersistentFlags().StringSliceVar(&Wallets, "wallets", nil, "serve info about passed wallets") rootCmd.PersistentFlags().StringSliceVar(&Validators, "validators", nil, "serve info about passed validators")