From e1eef2e81b51cde81400390815f8e4dde73ebe1a Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 19 Oct 2023 18:46:54 -0400 Subject: [PATCH] Change log messages for missing index prices to emit market id as a filterable field. (#668) (#672) (cherry picked from commit 1c285e71c5d6b6b634196f3249bd1500f9507340) Co-authored-by: Crystal Lemire --- protocol/x/perpetuals/keeper/perpetual.go | 9 +++++---- protocol/x/prices/keeper/update_price.go | 13 +++++++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/protocol/x/perpetuals/keeper/perpetual.go b/protocol/x/perpetuals/keeper/perpetual.go index 6b4b291c3f..0b00e5d3dc 100644 --- a/protocol/x/perpetuals/keeper/perpetual.go +++ b/protocol/x/perpetuals/keeper/perpetual.go @@ -2,6 +2,7 @@ package keeper import ( "fmt" + "github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/constants" "math/big" "math/rand" "sort" @@ -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, diff --git a/protocol/x/prices/keeper/update_price.go b/protocol/x/prices/keeper/update_price.go index e754165291..9816ce8f55 100644 --- a/protocol/x/prices/keeper/update_price.go +++ b/protocol/x/prices/keeper/update_price.go @@ -2,6 +2,7 @@ package keeper import ( "fmt" + "github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/constants" "sort" "time" @@ -69,7 +70,11 @@ 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 } @@ -77,7 +82,11 @@ func (k Keeper) GetValidMarketPriceUpdates( // 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 }