Skip to content

Commit

Permalink
Replace gauge with counter metric
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyson authored and Cyson committed Oct 23, 2023
1 parent 92141ee commit 9c018bf
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions modules/apps/transfer/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
Expand Down Expand Up @@ -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)},
)
Expand Down Expand Up @@ -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)},
)
Expand Down Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down

0 comments on commit 9c018bf

Please sign in to comment.