Skip to content
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

Update wallet_balance metric to f64 instead of u64 #2440

Merged
merged 5 commits into from
Jul 20, 2022

Conversation

ljoss17
Copy link
Contributor

@ljoss17 ljoss17 commented Jul 20, 2022

Closes: #2381

Description

This PR is an alternative solution to the PR #2425.
Instead of dividing the wallet_balance metric by a configurable order of magnitude, this PR updates the metric type from u64 to f64.

As f64::MAX is bigger than U256::MAX this solves the overflow problem without the need to divide the wallet_balance, thus does not introduce a new configurable value.


PR author checklist:

  • Added changelog entry, using unclog.
  • Added tests: integration (for Hermes) or unit/mock tests (for modules).
  • Linked to GitHub issue.
  • Updated code comments and documentation (e.g., docs/).

Reviewer checklist:

  • Reviewed Files changed in the GitHub PR explorer.
  • Manually tested (in case integration/unit/mock tests are absent).

@ljoss17 ljoss17 changed the title Updated 'wallet_balance' metric to be f64 instead of u64 Updated wallet_balance metric to f64 instead of u64 Jul 20, 2022
@ljoss17 ljoss17 changed the title Updated wallet_balance metric to f64 instead of u64 Update wallet_balance metric to f64 instead of u64 Jul 20, 2022
Copy link
Member

@romac romac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Let's also mention in the metric description and the changelog that the reported value may not be 100% accurate due to loss of precision when converting the balance to floating point.

%balance.amount, denom = %balance.denom, account = %key.account,
"Error parsing amount into f64 and therefore won't be reported to telemetry"
);
warn!(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this and make the trace above a warning instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handling the parsing error has been updated to only be a warning

relayer/src/worker/wallet.rs Outdated Show resolved Hide resolved
@romac romac merged commit c61ae18 into master Jul 20, 2022
@romac romac deleted the luca_joss/wallet_balance_metric_to_f64 branch July 20, 2022 11:51
hu55a1n1 pushed a commit to hu55a1n1/hermes that referenced this pull request Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prometheus metric wallet_balance incorrect
2 participants