Skip to content
This repository has been archived by the owner on Jan 29, 2019. It is now read-only.

Commit

Permalink
#187 update metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Stavetski committed May 2, 2018
1 parent ae7e04f commit 62df19f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const val NINE_HUNDRED_NINGTHY_FIVE_PERCENT = 0.95
const val TRADE_COUNT_METRIC = "trade_count"
const val TRADE_LATENCY_METRIC = "trade_latency"

const val ORDERBOOK_ASK_COUNT = "orderbook_ask_count"
const val ORDERBOOK_BID_COUNT = "orderbook_bid_count"
const val ORDERBOOK_SIZE_METRIC = "orderbook_size"

const val ORDER_TYPE_TAG = "order_type"
const val EXCHANGE_TAG = "exchange"
const val TOKENS_PAIR_TAG = "tokens_pair"
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import fund.cyber.markets.common.model.OrderType
import fund.cyber.markets.common.model.TokensPair
import fund.cyber.markets.connector.AbstarctXchangeConnector
import fund.cyber.markets.connector.configuration.EXCHANGE_TAG
import fund.cyber.markets.connector.configuration.ORDERBOOK_ASK_COUNT
import fund.cyber.markets.connector.configuration.ORDERBOOK_BID_COUNT
import fund.cyber.markets.connector.configuration.ORDERBOOK_SIZE_METRIC
import fund.cyber.markets.connector.configuration.ORDER_TYPE_TAG
import fund.cyber.markets.connector.configuration.TOKENS_PAIR_TAG
import info.bitrich.xchangestream.core.ProductSubscription
import info.bitrich.xchangestream.core.StreamingExchangeFactory
Expand Down Expand Up @@ -46,11 +46,13 @@ class XchangeOrderbookConnector : AbstarctXchangeConnector, OrderbookConnector {
log.info("Subscribing for orderbooks from $exchangeName exchange")

val exchangeTag = Tags.of(EXCHANGE_TAG, exchangeName)
exchangeTokensPairs.forEach { pair ->
val askOrderTag = Tags.of(ORDER_TYPE_TAG, OrderType.ASK.name)
val bidOrderTag = Tags.of(ORDER_TYPE_TAG, OrderType.BID.name)

exchangeTokensPairs.forEach { pair ->
val exchangePairTag = exchangeTag.and(Tags.of(TOKENS_PAIR_TAG, pair.base.currencyCode + "_" + pair.counter.currencyCode))
val askCountMonitor = monitoring.gauge(ORDERBOOK_ASK_COUNT, exchangePairTag, AtomicLong(0L))
val bidCountMonitor = monitoring.gauge(ORDERBOOK_BID_COUNT, exchangePairTag, AtomicLong(0L))
val askCountMonitor = monitoring.gauge(ORDERBOOK_SIZE_METRIC, exchangePairTag.and(askOrderTag), AtomicLong(0L))
val bidCountMonitor = monitoring.gauge(ORDERBOOK_SIZE_METRIC, exchangePairTag.and(bidOrderTag), AtomicLong(0L))

val orderbookSubscription = exchange.streamingMarketDataService
.getOrderBook(pair)
Expand Down

0 comments on commit 62df19f

Please sign in to comment.