Skip to content

Commit

Permalink
chore(price-feeder): improve provider logs (backport #1179) (#1181)
Browse files Browse the repository at this point in the history
beer pls
  • Loading branch information
mergify[bot] authored Jul 28, 2022
1 parent c1dd958 commit 40bf32e
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 17 deletions.
1 change: 1 addition & 0 deletions price-feeder/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion price-feeder/oracle/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions price-feeder/oracle/provider/binance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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{}
Expand Down
2 changes: 1 addition & 1 deletion price-feeder/oracle/provider/binance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down
2 changes: 1 addition & 1 deletion price-feeder/oracle/provider/coinbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion price-feeder/oracle/provider/coinbase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down
4 changes: 2 additions & 2 deletions price-feeder/oracle/provider/gate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion price-feeder/oracle/provider/gate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down
2 changes: 1 addition & 1 deletion price-feeder/oracle/provider/huobi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion price-feeder/oracle/provider/huobi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down
4 changes: 2 additions & 2 deletions price-feeder/oracle/provider/kraken.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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{}
Expand Down
2 changes: 1 addition & 1 deletion price-feeder/oracle/provider/kraken_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down
4 changes: 2 additions & 2 deletions price-feeder/oracle/provider/okx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion price-feeder/oracle/provider/okx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down

0 comments on commit 40bf32e

Please sign in to comment.