-
Notifications
You must be signed in to change notification settings - Fork 618
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
feat(transfer): move telemetry to internal folder #6513
Conversation
WalkthroughThe recent changes introduce telemetry functions to the Cosmos SDK application, specifically for tracking transfers and packet receptions within the IBC module. These additions involve new functions in the Changes
Sequence Diagram(s) (Beta)sequenceDiagram
participant User
participant App
participant Telemetry
User ->> App: Initiates Transfer
App ->> Telemetry: ReportTransferTelemetry(tokens, labels)
App ->> User: Transfer Confirmation
User ->> App: Receives Packet
App ->> Telemetry: ReportOnRecvPacketTelemetry(transferAmount, denomPath, labels)
App ->> User: Packet Reception Confirmation
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 2
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (2)
- modules/apps/transfer/internal/telemetry/telemetry.go (1 hunks)
- modules/apps/transfer/keeper/relay.go (5 hunks)
Additional context used
Path-based instructions (2)
modules/apps/transfer/internal/telemetry/telemetry.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.modules/apps/transfer/keeper/relay.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Additional comments not posted (2)
modules/apps/transfer/keeper/relay.go (2)
Line range hint
7-16
: Updated import statements align with the PR's objective to centralize telemetry logic.The removal of the alias for
go-metrics
and the addition ofinternaltelemetry
are consistent with the changes in the telemetry functions.
151-151
: Integration of new telemetry functions is correctly implemented.The deferred calls to
ReportTransferTelemetry
andReportOnRecvPacketTelemetry
at the end of the respective functions ensure that telemetry is recorded after all other operations are completed, which is a good practice.Also applies to: 215-215, 256-256
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, | ||
) | ||
} |
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.
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, | ||
) | ||
} |
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.
Ensure robust error handling when transferAmount.IsInt64()
returns false.
Similar to ReportTransferTelemetry
, this function does not handle the case where transferAmount.IsInt64()
returns false. Consider adding error logging or another form of notification to handle this scenario effectively.
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.
Love this change a lot! Thank you!
Quality Gate failed for 'ibc-go'Failed conditions |
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.
looks great, very nice to see this refactored out!
Description
Moves the big telemetry functions that take a lot of real estate space in the functions where they appear into an internal telemetry package.
Part of #6425. Can serve as an example and starting point for some "good first issue" issue(s).
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
).godoc
comments.Files changed
in the GitHub PR explorer.SonarCloud Report
in the comment section below once CI passes.Summary by CodeRabbit