Skip to content

Commit

Permalink
Change log messages for missing index prices to emit market id as a f…
Browse files Browse the repository at this point in the history
…ilterable field. (#668) (#672)

(cherry picked from commit 1c285e7)

Co-authored-by: Crystal Lemire <crystal.lemire@gmail.com>
  • Loading branch information
mergify[bot] and clemire authored Oct 19, 2023
1 parent b56a54d commit e1eef2e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
9 changes: 5 additions & 4 deletions protocol/x/perpetuals/keeper/perpetual.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"fmt"
"github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/constants"
"math/big"
"math/rand"
"sort"
Expand Down Expand Up @@ -449,10 +450,10 @@ func (k Keeper) sampleAllPerpetuals(ctx sdk.Context) (
// Only log and increment stats if height is passed initialization period.
if ctx.BlockHeight() > pricestypes.PriceDaemonInitializationBlocks {
k.Logger(ctx).Error(
fmt.Sprintf(
"Perpetual (%d) does not have valid index price. Skipping premium",
perp.Params.Id,
))
"Perpetual does not have valid index price. Skipping premium",
constants.MarketIdLogKey,
perp.Params.MarketId,
)
telemetry.IncrCounterWithLabels(
[]string{
types.ModuleName,
Expand Down
13 changes: 11 additions & 2 deletions protocol/x/prices/keeper/update_price.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"fmt"
"github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/constants"
"sort"
"time"

Expand Down Expand Up @@ -69,15 +70,23 @@ func (k Keeper) GetValidMarketPriceUpdates(
if k.IsRecentlyAvailable(ctx, marketId) {
logMethod = k.Logger(ctx).Info
}
logMethod(fmt.Sprintf("Index price for market (%v) does not exist", marketId))
logMethod(
"Index price for market does not exist",
constants.MarketIdLogKey,
marketId,
)
continue
}

// Index prices of 0 are unexpected. In this scenario, we skip the proposal logic for the market and report an
// error.
if indexPrice == 0 {
metrics.IncrCountMetricWithLabels(types.ModuleName, metrics.IndexPriceIsZero, marketMetricsLabel)
k.Logger(ctx).Error(fmt.Sprintf("Unexpected error: index price for market (%v) is zero", marketId))
k.Logger(ctx).Error(
"Unexpected error: index price for market is zero",
constants.MarketIdLogKey,
marketId,
)
continue
}

Expand Down

0 comments on commit e1eef2e

Please sign in to comment.