From 40bf32e4cf4c30ebcc006df46be9e63d2f4d5f3b Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 28 Jul 2022 14:56:19 -0700 Subject: [PATCH] chore(price-feeder): improve provider logs (backport #1179) (#1181) beer pls --- price-feeder/CHANGELOG.md | 1 + price-feeder/oracle/oracle.go | 2 +- price-feeder/oracle/provider/binance.go | 4 ++-- price-feeder/oracle/provider/binance_test.go | 2 +- price-feeder/oracle/provider/coinbase.go | 2 +- price-feeder/oracle/provider/coinbase_test.go | 2 +- price-feeder/oracle/provider/gate.go | 4 ++-- price-feeder/oracle/provider/gate_test.go | 2 +- price-feeder/oracle/provider/huobi.go | 2 +- price-feeder/oracle/provider/huobi_test.go | 2 +- price-feeder/oracle/provider/kraken.go | 4 ++-- price-feeder/oracle/provider/kraken_test.go | 2 +- price-feeder/oracle/provider/okx.go | 4 ++-- price-feeder/oracle/provider/okx_test.go | 2 +- 14 files changed, 18 insertions(+), 17 deletions(-) diff --git a/price-feeder/CHANGELOG.md b/price-feeder/CHANGELOG.md index d8d599218e..3724fd5851 100644 --- a/price-feeder/CHANGELOG.md +++ b/price-feeder/CHANGELOG.md @@ -52,6 +52,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements +- [#1179](https://github.com/umee-network/umee/pull/1179) Improve logs when unable to find prices. - [#978](https://github.com/umee-network/umee/pull/978) Cleanup the oracle package by moving deviation & conversion logic. ### Features diff --git a/price-feeder/oracle/oracle.go b/price-feeder/oracle/oracle.go index 5e0149c38c..e813710929 100644 --- a/price-feeder/oracle/oracle.go +++ b/price-feeder/oracle/oracle.go @@ -235,7 +235,7 @@ func (o *Oracle) SetPrices(ctx context.Context) error { } if err := g.Wait(); err != nil { - o.logger.Debug().Err(err).Msg("failed to get ticker prices from provider") + o.logger.Err(err).Msg("failed to get ticker prices from provider") } computedPrices, err := GetComputedPrices( diff --git a/price-feeder/oracle/provider/binance.go b/price-feeder/oracle/provider/binance.go index 7aecd40f45..28abd61b88 100644 --- a/price-feeder/oracle/provider/binance.go +++ b/price-feeder/oracle/provider/binance.go @@ -201,7 +201,7 @@ func (p *BinanceProvider) getTickerPrice(key string) (TickerPrice, error) { ticker, ok := p.tickers[key] if !ok { - return TickerPrice{}, fmt.Errorf("binance provider failed to get ticker price for %s", key) + return TickerPrice{}, fmt.Errorf("binance failed to get ticker price for %s", key) } return ticker.toTickerPrice() @@ -213,7 +213,7 @@ func (p *BinanceProvider) getCandlePrices(key string) ([]CandlePrice, error) { candles, ok := p.candles[key] if !ok { - return []CandlePrice{}, fmt.Errorf("failed to get candle prices for %s", key) + return []CandlePrice{}, fmt.Errorf("binance failed to get candle prices for %s", key) } candleList := []CandlePrice{} diff --git a/price-feeder/oracle/provider/binance_test.go b/price-feeder/oracle/provider/binance_test.go index bd0fe93c9b..275fa26214 100644 --- a/price-feeder/oracle/provider/binance_test.go +++ b/price-feeder/oracle/provider/binance_test.go @@ -68,7 +68,7 @@ func TestBinanceProvider_GetTickerPrices(t *testing.T) { t.Run("invalid_request_invalid_ticker", func(t *testing.T) { prices, err := p.GetTickerPrices(types.CurrencyPair{Base: "FOO", Quote: "BAR"}) require.Error(t, err) - require.Equal(t, "binance provider failed to get ticker price for FOOBAR", err.Error()) + require.Equal(t, "binance failed to get ticker price for FOOBAR", err.Error()) require.Nil(t, prices) }) } diff --git a/price-feeder/oracle/provider/coinbase.go b/price-feeder/oracle/provider/coinbase.go index 1c6c4e210f..463e94311c 100644 --- a/price-feeder/oracle/provider/coinbase.go +++ b/price-feeder/oracle/provider/coinbase.go @@ -288,7 +288,7 @@ func (p *CoinbaseProvider) getTickerPrice(cp types.CurrencyPair) (TickerPrice, e if tickerPair, ok := p.tickers[gp]; ok { return tickerPair.toTickerPrice() } else { - return TickerPrice{}, fmt.Errorf("failed to get ticker price for %s", gp) + return TickerPrice{}, fmt.Errorf("coinbase failed to get ticker price for %s", gp) } } diff --git a/price-feeder/oracle/provider/coinbase_test.go b/price-feeder/oracle/provider/coinbase_test.go index 4eda712810..cde7395ede 100644 --- a/price-feeder/oracle/provider/coinbase_test.go +++ b/price-feeder/oracle/provider/coinbase_test.go @@ -65,7 +65,7 @@ func TestCoinbaseProvider_GetTickerPrices(t *testing.T) { t.Run("invalid_request_invalid_ticker", func(t *testing.T) { prices, err := p.GetTickerPrices(types.CurrencyPair{Base: "FOO", Quote: "BAR"}) require.Error(t, err) - require.Equal(t, "failed to get ticker price for FOO-BAR", err.Error()) + require.Equal(t, "coinbase failed to get ticker price for FOO-BAR", err.Error()) require.Nil(t, prices) }) } diff --git a/price-feeder/oracle/provider/gate.go b/price-feeder/oracle/provider/gate.go index 1675086f9d..c7d10bab30 100644 --- a/price-feeder/oracle/provider/gate.go +++ b/price-feeder/oracle/provider/gate.go @@ -174,7 +174,7 @@ func (p *GateProvider) getCandlePrices(key string) ([]CandlePrice, error) { candles, ok := p.candles[key] if !ok { - return []CandlePrice{}, fmt.Errorf("failed to get candle prices for %s", key) + return []CandlePrice{}, fmt.Errorf("gate failed to get candle prices for %s", key) } candleList := []CandlePrice{} @@ -268,7 +268,7 @@ func (p *GateProvider) getTickerPrice(cp types.CurrencyPair) (TickerPrice, error if tickerPair, ok := p.tickers[gp]; ok { return tickerPair.toTickerPrice() } else { - return TickerPrice{}, fmt.Errorf("gate provider failed to get ticker price for %s", gp) + return TickerPrice{}, fmt.Errorf("gate failed to get ticker price for %s", gp) } } diff --git a/price-feeder/oracle/provider/gate_test.go b/price-feeder/oracle/provider/gate_test.go index 56047744a8..28429a919b 100644 --- a/price-feeder/oracle/provider/gate_test.go +++ b/price-feeder/oracle/provider/gate_test.go @@ -68,7 +68,7 @@ func TestGateProvider_GetTickerPrices(t *testing.T) { t.Run("invalid_request_invalid_ticker", func(t *testing.T) { prices, err := p.GetTickerPrices(types.CurrencyPair{Base: "FOO", Quote: "BAR"}) require.Error(t, err) - require.Equal(t, "gate provider failed to get ticker price for FOO_BAR", err.Error()) + require.Equal(t, "gate failed to get ticker price for FOO_BAR", err.Error()) require.Nil(t, prices) }) } diff --git a/price-feeder/oracle/provider/huobi.go b/price-feeder/oracle/provider/huobi.go index 67a1ab01fb..d918149be6 100644 --- a/price-feeder/oracle/provider/huobi.go +++ b/price-feeder/oracle/provider/huobi.go @@ -405,7 +405,7 @@ func (p *HuobiProvider) getTickerPrice(cp types.CurrencyPair) (TickerPrice, erro ticker, ok := p.tickers[currencyPairToHuobiTickerPair(cp)] if !ok { - return TickerPrice{}, fmt.Errorf("failed to get ticker price for %s", cp.String()) + return TickerPrice{}, fmt.Errorf("huobi failed to get ticker price for %s", cp.String()) } return ticker.toTickerPrice() diff --git a/price-feeder/oracle/provider/huobi_test.go b/price-feeder/oracle/provider/huobi_test.go index 98a0ca3ed3..fc19392a67 100644 --- a/price-feeder/oracle/provider/huobi_test.go +++ b/price-feeder/oracle/provider/huobi_test.go @@ -75,7 +75,7 @@ func TestHuobiProvider_GetTickerPrices(t *testing.T) { t.Run("invalid_request_invalid_ticker", func(t *testing.T) { prices, err := p.GetTickerPrices(types.CurrencyPair{Base: "FOO", Quote: "BAR"}) require.Error(t, err) - require.Equal(t, "failed to get ticker price for FOOBAR", err.Error()) + require.Equal(t, "huobi failed to get ticker price for FOOBAR", err.Error()) require.Nil(t, prices) }) } diff --git a/price-feeder/oracle/provider/kraken.go b/price-feeder/oracle/provider/kraken.go index e9fe6dfa48..2b35e83921 100644 --- a/price-feeder/oracle/provider/kraken.go +++ b/price-feeder/oracle/provider/kraken.go @@ -139,7 +139,7 @@ func (p *KrakenProvider) GetTickerPrices(pairs ...types.CurrencyPair) (map[strin key := cp.String() tickerPrice, ok := p.tickers[key] if !ok { - return nil, fmt.Errorf("failed to get ticker price for %s", key) + return nil, fmt.Errorf("kraken failed to get ticker price for %s", key) } tickerPrices[key] = tickerPrice } @@ -224,7 +224,7 @@ func (p *KrakenProvider) getCandlePrices(key string) ([]CandlePrice, error) { candles, ok := p.candles[key] if !ok { - return []CandlePrice{}, fmt.Errorf("failed to get candle prices for %s", key) + return []CandlePrice{}, fmt.Errorf("kraken failed to get candle prices for %s", key) } candleList := []CandlePrice{} diff --git a/price-feeder/oracle/provider/kraken_test.go b/price-feeder/oracle/provider/kraken_test.go index ec030f7135..b3debe4605 100644 --- a/price-feeder/oracle/provider/kraken_test.go +++ b/price-feeder/oracle/provider/kraken_test.go @@ -65,7 +65,7 @@ func TestKrakenProvider_GetTickerPrices(t *testing.T) { t.Run("invalid_request_invalid_ticker", func(t *testing.T) { prices, err := p.GetTickerPrices(types.CurrencyPair{Base: "FOO", Quote: "BAR"}) require.Error(t, err) - require.Equal(t, "failed to get ticker price for FOOBAR", err.Error()) + require.Equal(t, "kraken failed to get ticker price for FOOBAR", err.Error()) require.Nil(t, prices) }) } diff --git a/price-feeder/oracle/provider/okx.go b/price-feeder/oracle/provider/okx.go index 70678eb261..c0f7a1f4a5 100644 --- a/price-feeder/oracle/provider/okx.go +++ b/price-feeder/oracle/provider/okx.go @@ -233,7 +233,7 @@ func (p *OkxProvider) getTickerPrice(cp types.CurrencyPair) (TickerPrice, error) instrumentId := currencyPairToOkxPair(cp) tickerPair, ok := p.tickers[instrumentId] if !ok { - return TickerPrice{}, fmt.Errorf("okx provider failed to get ticker price for %s", instrumentId) + return TickerPrice{}, fmt.Errorf("okx failed to get ticker price for %s", instrumentId) } return tickerPair.toTickerPrice() @@ -246,7 +246,7 @@ func (p *OkxProvider) getCandlePrices(cp types.CurrencyPair) ([]CandlePrice, err instrumentId := currencyPairToOkxPair(cp) candles, ok := p.candles[instrumentId] if !ok { - return []CandlePrice{}, fmt.Errorf("failed to get candle prices for %s", instrumentId) + return []CandlePrice{}, fmt.Errorf("okx failed to get candle prices for %s", instrumentId) } candleList := []CandlePrice{} for _, candle := range candles { diff --git a/price-feeder/oracle/provider/okx_test.go b/price-feeder/oracle/provider/okx_test.go index 574880546e..20427d7ff0 100644 --- a/price-feeder/oracle/provider/okx_test.go +++ b/price-feeder/oracle/provider/okx_test.go @@ -74,7 +74,7 @@ func TestOkxProvider_GetTickerPrices(t *testing.T) { t.Run("invalid_request_invalid_ticker", func(t *testing.T) { prices, err := p.GetTickerPrices(types.CurrencyPair{Base: "FOO", Quote: "BAR"}) require.Error(t, err) - require.Equal(t, "okx provider failed to get ticker price for FOO-BAR", err.Error()) + require.Equal(t, "okx failed to get ticker price for FOO-BAR", err.Error()) require.Nil(t, prices) }) }