From 9c018bf8a7f58161de3d84e5e30510f1f97e6a30 Mon Sep 17 00:00:00 2001 From: Cyson Date: Tue, 17 Oct 2023 10:57:00 -0700 Subject: [PATCH] Replace gauge with counter metric --- modules/apps/transfer/keeper/relay.go | 30 ++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/modules/apps/transfer/keeper/relay.go b/modules/apps/transfer/keeper/relay.go index 6fcd135c..8e9db623 100644 --- a/modules/apps/transfer/keeper/relay.go +++ b/modules/apps/transfer/keeper/relay.go @@ -200,7 +200,7 @@ func (k Keeper) sendTransfer( defer func() { if token.Amount.IsInt64() { - telemetry.SetGaugeWithLabels( + telemetry.IncrCounterWithLabels( []string{"tx", "msg", "ibc", "transfer"}, float32(token.Amount.Int64()), []metrics.Label{telemetry.NewLabel(coretypes.LabelDenom, fullDenomPath)}, @@ -291,8 +291,8 @@ func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, data t defer func() { if transferAmount.IsInt64() { - telemetry.SetGaugeWithLabels( - []string{"ibc", types.ModuleName, "packet", "receive"}, + telemetry.IncrCounterWithLabels( + []string{"ibc", types.ModuleName, "packet", "receive", "native"}, float32(transferAmount.Int64()), []metrics.Label{telemetry.NewLabel(coretypes.LabelDenom, unprefixedDenom)}, ) @@ -351,8 +351,8 @@ func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, data t defer func() { if transferAmount.IsInt64() { - telemetry.SetGaugeWithLabels( - []string{"ibc", types.ModuleName, "packet", "receive"}, + telemetry.IncrCounterWithLabels( + []string{"ibc", types.ModuleName, "packet", "receive", "non-native"}, float32(transferAmount.Int64()), []metrics.Label{telemetry.NewLabel(coretypes.LabelDenom, data.Denom)}, ) @@ -425,6 +425,16 @@ func (k Keeper) refundPacketToken(ctx sdk.Context, packet channeltypes.Packet, d return sdkerrors.Wrap(err, "unable to unescrow tokens, this may be caused by a malicious counterparty module or a bug: please open an issue on counterparty module") } + defer func() { + if transferAmount.IsInt64() { + telemetry.IncrCounterWithLabels( + []string{"ibc", types.ModuleName, "refund"}, + float32(transferAmount.Int64()), + []metrics.Label{telemetry.NewLabel(coretypes.LabelDenom, data.Denom)}, + ) + } + }() + return nil } @@ -439,6 +449,16 @@ func (k Keeper) refundPacketToken(ctx sdk.Context, packet channeltypes.Packet, d panic(fmt.Sprintf("unable to send coins from module to account despite previously minting coins to module account: %v", err)) } + defer func() { + if transferAmount.IsInt64() { + telemetry.IncrCounterWithLabels( + []string{"ibc", types.ModuleName, "burn"}, + float32(transferAmount.Int64()), + []metrics.Label{telemetry.NewLabel(coretypes.LabelDenom, data.Denom)}, + ) + } + }() + return nil }