Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove a couple of metrics calls #3703

Merged
merged 1 commit into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions execution/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -1896,8 +1896,6 @@ func (m *Market) zeroOutNetwork(ctx context.Context, traders []events.MarketPosi
}

func (m *Market) checkMarginForOrder(ctx context.Context, pos *positions.MarketPosition, order *types.Order) error {
timer := metrics.NewTimeCounter(m.mkt.Id, "market", "checkMarginForOrder")
defer timer.EngineTimeCounterAdd()
risk, closed, err := m.calcMargins(ctx, pos, order)
// margin error
if err != nil {
Expand Down
5 changes: 0 additions & 5 deletions matching/orderbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"code.vegaprotocol.io/vega/crypto"
"code.vegaprotocol.io/vega/events"
"code.vegaprotocol.io/vega/logging"
"code.vegaprotocol.io/vega/metrics"
"code.vegaprotocol.io/vega/types"
"code.vegaprotocol.io/vega/types/num"

Expand Down Expand Up @@ -688,10 +687,7 @@ func (b *OrderBook) GetTrades(order *types.Order) ([]*types.Trade, error) {

// SubmitOrder Add an order and attempt to uncross the book, returns a TradeSet protobuf message object
func (b *OrderBook) SubmitOrder(order *types.Order) (*types.OrderConfirmation, error) {
timer := metrics.NewTimeCounter(b.marketID, "matching", "SubmitOrder")

if err := b.validateOrder(order); err != nil {
timer.EngineTimeCounterAdd()
return nil, err
}

Expand Down Expand Up @@ -796,7 +792,6 @@ func (b *OrderBook) SubmitOrder(order *types.Order) (*types.OrderConfirmation, e
}

orderConfirmation := makeResponse(order, trades, impactedOrders)
timer.EngineTimeCounterAdd()
return orderConfirmation, nil
}

Expand Down
5 changes: 0 additions & 5 deletions matching/side.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"code.vegaprotocol.io/vega/crypto"
"code.vegaprotocol.io/vega/logging"
"code.vegaprotocol.io/vega/metrics"
"code.vegaprotocol.io/vega/types"
"code.vegaprotocol.io/vega/types/num"

Expand Down Expand Up @@ -399,8 +398,6 @@ func (s *OrderBookSide) fakeUncross(agg *types.Order) ([]*types.Trade, error) {
}

func (s *OrderBookSide) uncross(agg *types.Order, checkWashTrades bool) ([]*types.Trade, []*types.Order, *num.Uint, error) {
timer := metrics.NewTimeCounter("-", "matching", "OrderBookSide.uncross")

var (
trades []*types.Trade
impactedOrders []*types.Order
Expand Down Expand Up @@ -446,7 +443,6 @@ func (s *OrderBookSide) uncross(agg *types.Order, checkWashTrades bool) ([]*type
}

if totalVolumeToFill < agg.Remaining {
timer.EngineTimeCounterAdd()
return trades, impactedOrders, lastTradedPrice, nil
}
}
Expand Down Expand Up @@ -513,7 +509,6 @@ func (s *OrderBookSide) uncross(agg *types.Order, checkWashTrades bool) ([]*type
if len(trades) > 0 {
lastTradedPrice = trades[len(trades)-1].Price.Clone()
}
timer.EngineTimeCounterAdd()
return trades, impactedOrders, lastTradedPrice, err
}

Expand Down
3 changes: 0 additions & 3 deletions matching/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package matching

import (
"code.vegaprotocol.io/vega/logging"
"code.vegaprotocol.io/vega/metrics"
"code.vegaprotocol.io/vega/types"
"code.vegaprotocol.io/vega/types/num"
)
Expand All @@ -11,7 +10,6 @@ const minOrderIDLen = 22
const maxOrderIDLen = 22

func (b OrderBook) validateOrder(orderMessage *types.Order) (err error) {
timer := metrics.NewTimeCounter(b.marketID, "matching", "validateOrder")
if orderMessage.Price == nil {
orderMessage.Price = num.Zero()
}
Expand Down Expand Up @@ -48,7 +46,6 @@ func (b OrderBook) validateOrder(orderMessage *types.Order) (err error) {
} else if orderMessage.ExpiresAt > 0 && orderMessage.Type == types.Order_TYPE_MARKET {
err = types.ErrInvalidExpirationDatetime
}
timer.EngineTimeCounterAdd()
return
}

Expand Down
8 changes: 0 additions & 8 deletions positions/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"code.vegaprotocol.io/vega/crypto"
"code.vegaprotocol.io/vega/events"
"code.vegaprotocol.io/vega/logging"
"code.vegaprotocol.io/vega/metrics"
"code.vegaprotocol.io/vega/types"
"code.vegaprotocol.io/vega/types/num"
)
Expand Down Expand Up @@ -102,7 +101,6 @@ func (e *Engine) ReloadConf(cfg Config) {
// The margins+risk engines need the updated position to determine whether the
// order should be accepted.
func (e *Engine) RegisterOrder(order *types.Order) *MarketPosition {
timer := metrics.NewTimeCounter("-", "positions", "RegisterOrder")
pos, found := e.positions[order.PartyId]
if !found {
pos = NewMarketPosition(order.PartyId)
Expand All @@ -111,15 +109,12 @@ func (e *Engine) RegisterOrder(order *types.Order) *MarketPosition {
e.positionsCpy = append(e.positionsCpy, pos)
}
pos.RegisterOrder(order)
timer.EngineTimeCounterAdd()
return pos
}

// UnregisterOrder undoes the actions of RegisterOrder. It is used when an order
// has been rejected by the Risk Engine, or when an order is amended or canceled.
func (e *Engine) UnregisterOrder(order *types.Order) *MarketPosition {
defer metrics.NewTimeCounter("-", "positions", "UnregisterOrder").EngineTimeCounterAdd()

pos, found := e.positions[order.PartyId]
if !found {
e.log.Panic("could not find position in engine when unregistering order",
Expand All @@ -133,16 +128,13 @@ func (e *Engine) UnregisterOrder(order *types.Order) *MarketPosition {
// AmendOrder unregisters the original order and then registers the newly amended order
// this method is a quicker way of handling separate unregister+register pairs
func (e *Engine) AmendOrder(originalOrder, newOrder *types.Order) *MarketPosition {
timer := metrics.NewTimeCounter("-", "positions", "AmendOrder")

pos, found := e.positions[originalOrder.PartyId]
if !found {
e.log.Panic("could not find position in engine when amending order",
logging.Order(*originalOrder),
logging.Order(*newOrder))
}
pos.AmendOrder(e.log, originalOrder, newOrder)
timer.EngineTimeCounterAdd()
return pos
}

Expand Down