Skip to content

Commit

Permalink
Merge pull request #1831 from c9s/c9s/share-stream-book-metrics-labels
Browse files Browse the repository at this point in the history
REFACTOR: share stream book metrics labels
  • Loading branch information
c9s authored Nov 18, 2024
2 parents 0399cd1 + e497b8b commit 1101172
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/types/orderbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,12 @@ func (sb *StreamOrderBook) updateMetrics(t time.Time) {
bestBid, bestAsk, ok := sb.BestBidAndAsk()
if ok {
exchangeName := string(sb.Exchange)
streamOrderBookBestAskPriceMetrics.WithLabelValues(sb.Symbol, exchangeName).Set(bestAsk.Price.Float64())
streamOrderBookBestBidPriceMetrics.WithLabelValues(sb.Symbol, exchangeName).Set(bestBid.Price.Float64())
streamOrderBookBestAskVolumeMetrics.WithLabelValues(sb.Symbol, exchangeName).Set(bestAsk.Volume.Float64())
streamOrderBookBestBidVolumeMetrics.WithLabelValues(sb.Symbol, exchangeName).Set(bestBid.Volume.Float64())
streamOrderBookUpdateTimeMetrics.WithLabelValues(sb.Symbol, exchangeName).Set(float64(t.UnixMilli()))
labels := prometheus.Labels{"symbol": sb.Symbol, "exchange": exchangeName}
streamOrderBookBestAskPriceMetrics.With(labels).Set(bestAsk.Price.Float64())
streamOrderBookBestBidPriceMetrics.With(labels).Set(bestBid.Price.Float64())
streamOrderBookBestAskVolumeMetrics.With(labels).Set(bestAsk.Volume.Float64())
streamOrderBookBestBidVolumeMetrics.With(labels).Set(bestBid.Volume.Float64())
streamOrderBookUpdateTimeMetrics.With(labels).Set(float64(t.UnixMilli()))
}
}

Expand Down

0 comments on commit 1101172

Please sign in to comment.