-
Notifications
You must be signed in to change notification settings - Fork 623
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
feat(transfer): move telemetry to internal folder #6513
Changes from all commits
ac0b6f5
8e73739
f01a02b
5f56a5e
cbc1bea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package telemetry | ||
|
||
import ( | ||
"github.com/hashicorp/go-metrics" | ||
|
||
sdkmath "cosmossdk.io/math" | ||
|
||
"github.com/cosmos/cosmos-sdk/telemetry" | ||
|
||
"github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" | ||
coretypes "github.com/cosmos/ibc-go/v8/modules/core/types" | ||
) | ||
|
||
func ReportTransferTelemetry(tokens types.Tokens, labels []metrics.Label) { | ||
for _, token := range tokens { | ||
amount, ok := sdkmath.NewIntFromString(token.Amount) | ||
if ok && amount.IsInt64() { | ||
telemetry.SetGaugeWithLabels( | ||
[]string{"tx", "msg", "ibc", "transfer"}, | ||
float32(amount.Int64()), | ||
[]metrics.Label{telemetry.NewLabel(coretypes.LabelDenom, token.Denom.Path())}, | ||
) | ||
} | ||
} | ||
|
||
telemetry.IncrCounterWithLabels( | ||
[]string{"ibc", types.ModuleName, "send"}, | ||
1, | ||
labels, | ||
) | ||
} | ||
|
||
func ReportOnRecvPacketTelemetry(transferAmount sdkmath.Int, denomPath string, labels []metrics.Label) { | ||
if transferAmount.IsInt64() { | ||
telemetry.SetGaugeWithLabels( | ||
[]string{"ibc", types.ModuleName, "packet", "receive"}, | ||
float32(transferAmount.Int64()), | ||
[]metrics.Label{telemetry.NewLabel(coretypes.LabelDenom, denomPath)}, | ||
) | ||
} | ||
|
||
telemetry.IncrCounterWithLabels( | ||
[]string{"ibc", types.ModuleName, "receive"}, | ||
1, | ||
labels, | ||
) | ||
} | ||
Comment on lines
+33
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure robust error handling when Similar to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider handling the case where
amount.IsInt64()
returns false.Currently, if
amount.IsInt64()
returns false, the function silently skips recording telemetry for that token. It might be beneficial to log this occurrence or handle it in a way that ensures visibility of the issue.