metrics: use uint64 for Counter and Gauge types#4911
Merged
algorandskiy merged 4 commits intoalgorand:masterfrom Jan 9, 2023
Merged
metrics: use uint64 for Counter and Gauge types#4911algorandskiy merged 4 commits intoalgorand:masterfrom
algorandskiy merged 4 commits intoalgorand:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4911 +/- ##
==========================================
- Coverage 53.64% 53.62% -0.02%
==========================================
Files 432 432
Lines 54058 54052 -6
==========================================
- Hits 28997 28987 -10
- Misses 22813 22817 +4
Partials 2248 2248
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
brianolson
reviewed
Dec 21, 2022
Contributor
brianolson
left a comment
There was a problem hiding this comment.
99% love it. about time. but we should go ahead and use sync/atomic in this change
| // Add increases gauge by x | ||
| func (gauge *Gauge) Add(x float64) { | ||
| func (gauge *Gauge) Add(x uint64) { | ||
| gauge.Lock() |
Contributor
There was a problem hiding this comment.
go ahead and use sync/atomic?
| name string | ||
| description string | ||
| value float64 | ||
| value uint64 |
Contributor
There was a problem hiding this comment.
move to first member of struct for better sync/atomic safety?
Contributor
Author
There was a problem hiding this comment.
also done, thanks for the tip
| // For adding an integer, see AddUint64(x) | ||
| func (counter *Counter) Add(x float64, labels map[string]string) { | ||
| // addLabels increases counter by x | ||
| func (counter *Counter) addLabels(x uint64, labels map[string]string) { |
Contributor
There was a problem hiding this comment.
I like that this was changed and nothing was lost because everything was already using AddUint64
algorandskiy
approved these changes
Jan 6, 2023
winder
pushed a commit
to winder/go-algorand
that referenced
this pull request
Jan 18, 2023
This was referenced Jan 23, 2023
This was referenced Jan 30, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Our counters and gauges support float64, but we never use anything but uint64, so this switches them to be uint64 metrics.
Test Plan
Updated tests in the metrics package.