Skip to content

Instantly share code, notes, and snippets.

@gloriousCode
Created August 25, 2023 00:12
Show Gist options
  • Save gloriousCode/60510d8143fe779578d60f6c9cd229f0 to your computer and use it in GitHub Desktop.
Save gloriousCode/60510d8143fe779578d60f6c9cd229f0 to your computer and use it in GitHub Desktop.
logs
diff --git a/exchanges/orderbook/orderbook.go b/exchanges/orderbook/orderbook.go
index 42ece3929..0683aa299 100644
--- a/exchanges/orderbook/orderbook.go
+++ b/exchanges/orderbook/orderbook.go
@@ -15,12 +15,20 @@ import (
// Get checks and returns the orderbook given an exchange name and currency pair
func Get(exchange string, p currency.Pair, a asset.Item) (*Base, error) {
+ tt := time.Now()
+ defer func() {
+ log.Debugln(log.OrderBook, "get for ", exchange, " ", a, " ", p, " took: ", time.Since(tt))
+ }()
return service.Retrieve(exchange, p, a)
}
// GetDepth returns a Depth pointer allowing the caller to stream orderbook
// changes
func GetDepth(exchange string, p currency.Pair, a asset.Item) (*Depth, error) {
+ tt := time.Now()
+ defer func() {
+ log.Debugln(log.OrderBook, "get depth for ", exchange, " ", a, " ", p, " took: ", time.Since(tt))
+ }()
return service.GetDepth(exchange, p, a)
}
@@ -28,6 +36,10 @@ func GetDepth(exchange string, p currency.Pair, a asset.Item) (*Depth, error) {
// the loading of a new orderbook snapshot and incremental updates via the
// streaming package.
func DeployDepth(exchange string, p currency.Pair, a asset.Item) (*Depth, error) {
+ tt := time.Now()
+ defer func() {
+ log.Debugln(log.OrderBook, "deploy depth for ", exchange, " ", a, " ", p, " took: ", time.Since(tt))
+ }()
return service.DeployDepth(exchange, p, a)
}
@@ -307,6 +319,10 @@ func (b *Base) Process() error {
if err := b.Verify(); err != nil {
return err
}
+ tt := time.Now()
+ defer func() {
+ log.Debugln(log.OrderBook, "process book for ", b.Exchange, " ", b.Asset, " ", b.Pair, " took: ", time.Since(tt))
+ }()
return service.Update(b)
}
diff --git a/exchanges/ticker/ticker.go b/exchanges/ticker/ticker.go
index a1cd1a3ea..fd072786c 100644
--- a/exchanges/ticker/ticker.go
+++ b/exchanges/ticker/ticker.go
@@ -11,6 +11,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/currency"
"github.com/thrasher-corp/gocryptotrader/dispatch"
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
+ "github.com/thrasher-corp/gocryptotrader/log"
)
var (
@@ -75,8 +76,14 @@ func GetTicker(exchange string, p currency.Pair, a asset.Item) (*Price, error) {
return nil, fmt.Errorf("%w %v", asset.ErrNotSupported, a)
}
exchange = strings.ToLower(exchange)
+
service.mu.Lock()
defer service.mu.Unlock()
+ tt := time.Now()
+ defer func() {
+ log.Debugln(log.Ticker, "get ticker for ", exchange, " ", a, " ", p, " took: ", time.Since(tt))
+ }()
+
tick, ok := service.Tickers[key.ExchangePairAssetKey{
Exchange: exchange,
Base: p.Base.Item,
@@ -155,6 +162,10 @@ func ProcessTicker(p *Price) error {
p.LastUpdated = time.Now()
}
+ tt := time.Now()
+ defer func() {
+ log.Debugln(log.Ticker, "process ticker for ", strings.ToLower(p.ExchangeName), " ", p.AssetType, " ", p.Pair, " took: ", time.Since(tt))
+ }()
return service.update(p)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment