Skip to content

Commit

Permalink
feat: price-feeder: telemetry additions (#673) (#676)
Browse files Browse the repository at this point in the history
* add telemetry for websocket reconnection attempts & receiving candles / ticker messages

* add "missed vote" telemetry

* fix telemetry src

* add a telemetry counter for subscriptions to cps

* Update price-feeder/oracle/provider/gate.go

Co-authored-by: Adam Moser <63419657+toteki@users.noreply.github.com>

* Update price-feeder/oracle/provider/huobi.go

Co-authored-by: Adam Moser <63419657+toteki@users.noreply.github.com>

* Batch of 3

Co-authored-by: Adam Moser <63419657+toteki@users.noreply.github.com>
(cherry picked from commit 0c65084)

Co-authored-by: Adam Wozniak <29418299+adamewozniak@users.noreply.github.com>
  • Loading branch information
mergify[bot] and adamewozniak authored Mar 23, 2022
1 parent 7a79c9b commit b2ee6bc
Show file tree
Hide file tree
Showing 7 changed files with 209 additions and 0 deletions.
1 change: 1 addition & 0 deletions price-feeder/oracle/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ func (o *Oracle) tick(ctx context.Context) error {
Float64("previous_vote_period", o.previousVotePeriod).
Float64("current_vote_period", currentVotePeriod).
Msg("missing vote during voting period")
telemetry.IncrCounter(1, "vote", "failure", "missed")

o.previousVotePeriod = 0
o.previousPrevote = nil
Expand Down
28 changes: 28 additions & 0 deletions price-feeder/oracle/provider/binance.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import (

"github.com/gorilla/websocket"
"github.com/rs/zerolog"
"github.com/umee-network/umee/price-feeder/config"
"github.com/umee-network/umee/price-feeder/oracle/types"
"github.com/umee-network/umee/price-feeder/telemetry"
)

const (
Expand Down Expand Up @@ -237,6 +239,15 @@ func (p *BinanceProvider) messageReceived(messageType int, bz []byte) {
}
if len(tickerResp.LastPrice) != 0 {
p.setTickerPair(tickerResp)
telemetry.IncrCounter(
1,
"websocket",
"message",
"type",
"ticker",
"provider",
config.ProviderBinance,
)
return
}

Expand All @@ -246,6 +257,15 @@ func (p *BinanceProvider) messageReceived(messageType int, bz []byte) {
}
if len(candleResp.Metadata.Close) != 0 {
p.setCandlePair(candleResp)
telemetry.IncrCounter(
1,
"websocket",
"message",
"type",
"candle",
"provider",
config.ProviderBinance,
)
}
}

Expand Down Expand Up @@ -327,6 +347,14 @@ func (p *BinanceProvider) reconnect() error {
p.wsClient = wsConn

currencyPairs := p.subscribedPairsToSlice()

telemetry.IncrCounter(
1,
"websocket",
"reconnect",
"provider",
config.ProviderBinance,
)
return p.subscribeChannels(currencyPairs...)
}

Expand Down
36 changes: 36 additions & 0 deletions price-feeder/oracle/provider/coinbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import (
"github.com/rs/zerolog"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/umee-network/umee/price-feeder/config"
"github.com/umee-network/umee/price-feeder/oracle/types"
"github.com/umee-network/umee/price-feeder/telemetry"
)

const (
Expand Down Expand Up @@ -211,6 +213,14 @@ func (p *CoinbaseProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair) err
return err
}
p.setSubscribedPairs(cps...)
telemetry.IncrCounter(
float32(len(cps)),
"websocket",
"subscribe",
"currency_pairs",
"provider",
config.ProviderCoinbase,
)
return nil
}

Expand Down Expand Up @@ -347,8 +357,26 @@ func (p *CoinbaseProvider) messageReceived(messageType int, bz []byte) {
p.logger.Debug().Msg("unable to unmarshal response")
}
p.setTickerPair(coinbaseTicker)
telemetry.IncrCounter(
1,
"websocket",
"message",
"type",
"ticker",
"provider",
config.ProviderCoinbase,
)
return
}
telemetry.IncrCounter(
1,
"websocket",
"message",
"type",
"trade",
"provider",
config.ProviderCoinbase,
)
p.setTradePair(coinbaseTrade)
}

Expand Down Expand Up @@ -437,6 +465,14 @@ func (p *CoinbaseProvider) reconnect() error {
p.wsClient = wsConn

currencyPairs := p.subscribedPairsToSlice()

telemetry.IncrCounter(
1,
"websocket",
"reconnect",
"provider",
config.ProviderCoinbase,
)
return p.SubscribeCurrencyPairs(currencyPairs...)
}

Expand Down
36 changes: 36 additions & 0 deletions price-feeder/oracle/provider/gate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import (

"github.com/gorilla/websocket"
"github.com/rs/zerolog"
"github.com/umee-network/umee/price-feeder/telemetry"

"github.com/umee-network/umee/price-feeder/config"
"github.com/umee-network/umee/price-feeder/oracle/types"
)

Expand Down Expand Up @@ -197,6 +199,14 @@ func (p *GateProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair) error {
return err
}
p.setSubscribedPairs(cps...)
telemetry.IncrCounter(
float32(len(cps)),
"websocket",
"subscribe",
"currency_pairs",
"provider",
config.ProviderGate,
)
return nil
}

Expand Down Expand Up @@ -352,6 +362,15 @@ func (p *GateProvider) messageReceivedTickerPrice(bz []byte) error {
gateTicker.Symbol = symbol

p.setTickerPair(gateTicker)
telemetry.IncrCounter(
1,
"websocket",
"message",
"type",
"ticker",
"provider",
config.ProviderGate,
)
return nil
}

Expand Down Expand Up @@ -417,6 +436,15 @@ func (p *GateProvider) messageReceivedCandle(bz []byte) error {
}

p.setCandlePair(gateCandle)
telemetry.IncrCounter(
1,
"websocket",
"message",
"type",
"candle",
"provider",
config.ProviderGate,
)
return nil
}

Expand Down Expand Up @@ -489,6 +517,14 @@ func (p *GateProvider) reconnect() error {
p.wsClient = wsConn

currencyPairs := p.subscribedPairsToSlice()

telemetry.IncrCounter(
1,
"websocket",
"reconnect",
"provider",
config.ProviderGate,
)
return p.SubscribeCurrencyPairs(currencyPairs...)
}

Expand Down
36 changes: 36 additions & 0 deletions price-feeder/oracle/provider/huobi.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import (

"github.com/gorilla/websocket"
"github.com/rs/zerolog"
"github.com/umee-network/umee/price-feeder/config"
"github.com/umee-network/umee/price-feeder/oracle/types"
"github.com/umee-network/umee/price-feeder/telemetry"
)

const (
Expand Down Expand Up @@ -157,6 +159,14 @@ func (p *HuobiProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair) error
}

p.setSubscribedPairs(cps...)
telemetry.IncrCounter(
float32(len(cps)),
"websocket",
"subscribe",
"currency_pairs",
"provider",
config.ProviderHuobi,
)
return nil
}

Expand Down Expand Up @@ -264,6 +274,15 @@ func (p *HuobiProvider) messageReceived(messageType int, bz []byte, reconnectTic
}
if tickerResp.Tick.LastPrice != 0 {
p.setTickerPair(tickerResp)
telemetry.IncrCounter(
1,
"websocket",
"message",
"type",
"ticker",
"provider",
config.ProviderHuobi,
)
return
}

Expand All @@ -273,6 +292,15 @@ func (p *HuobiProvider) messageReceived(messageType int, bz []byte, reconnectTic
}
if candleResp.Tick.Close != 0 {
p.setCandlePair(candleResp)
telemetry.IncrCounter(
1,
"websocket",
"message",
"type",
"candle",
"provider",
config.ProviderHuobi,
)
}
}

Expand Down Expand Up @@ -340,6 +368,14 @@ func (p *HuobiProvider) reconnect() error {
p.wsClient = wsConn

currencyPairs := p.subscribedPairsToSlice()

telemetry.IncrCounter(
1,
"websocket",
"reconnect",
"provider",
config.ProviderHuobi,
)
return p.subscribeChannels(currencyPairs...)
}

Expand Down
36 changes: 36 additions & 0 deletions price-feeder/oracle/provider/kraken.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import (

"github.com/gorilla/websocket"
"github.com/rs/zerolog"
"github.com/umee-network/umee/price-feeder/config"
"github.com/umee-network/umee/price-feeder/oracle/types"
"github.com/umee-network/umee/price-feeder/telemetry"
)

const (
Expand Down Expand Up @@ -168,6 +170,14 @@ func (p *KrakenProvider) SubscribeCurrencyPairs(cps ...types.CurrencyPair) error
}

p.setSubscribedPairs(cps...)
telemetry.IncrCounter(
float32(len(cps)),
"websocket",
"subscribe",
"currency_pairs",
"provider",
config.ProviderKraken,
)
return nil
}

Expand Down Expand Up @@ -345,6 +355,15 @@ func (p *KrakenProvider) messageReceivedTickerPrice(bz []byte) error {
}

p.setTickerPair(currencyPairSymbol, tickerPrice)
telemetry.IncrCounter(
1,
"websocket",
"message",
"type",
"ticker",
"provider",
config.ProviderKraken,
)
return nil
}

Expand Down Expand Up @@ -420,6 +439,15 @@ func (p *KrakenProvider) messageReceivedCandle(bz []byte) error {
currencyPairSymbol := krakenPairToCurrencyPairSymbol(krakenPair)
krakenCandle.Symbol = currencyPairSymbol

telemetry.IncrCounter(
1,
"websocket",
"message",
"type",
"candle",
"provider",
config.ProviderKraken,
)
p.setCandlePair(krakenCandle)
return nil
}
Expand All @@ -436,6 +464,14 @@ func (p *KrakenProvider) reconnect() error {
p.wsClient = wsConn

currencyPairs := p.subscribedPairsToSlice()

telemetry.IncrCounter(
1,
"websocket",
"reconnect",
"provider",
config.ProviderKraken,
)
return p.subscribeChannels(currencyPairs...)
}

Expand Down
Loading

0 comments on commit b2ee6bc

Please sign in to comment.