-
Notifications
You must be signed in to change notification settings - Fork 131
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
add delete-gauges flag to support re-sending a value when there was no u... #62
Conversation
ed1b034
to
3f8005d
Compare
Did not notice there was an existing pull, #58. This has tests for the case where the flag is set to false as well. |
I guess the difference being we don't wan't "unchanged form last value" we want "any update or not" even if it's the same value. |
3f8005d
to
98c338e
Compare
Updated. |
98c338e
to
4b969a6
Compare
continue | ||
} else if ok && lastValue > 0 && c == math.MaxUint64 && *deleteGauges == false { |
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.
I think this is functional, but the length of these if statements is getting hard to parse. Any ideas for simplifying? Typically idiomatic Go moves longer if/else if/else if/else into a switch block to simplify.... (my attempt below)
currentValue := c
lastValue, hasLastValue := trackedGauges[g]
var hasChanged bool
if c != math.MaxUint64 {
hasChanged = true
}
switch {
case hasChanged:
fmt.Fprintf(buffer, "%s %d %d\n", g, currentValue, now)
trackedGauges[g] = c
gauges[g] = math.MaxUint64
num++
case !hasChanged && hasLastValue && !*deleteGauges:
fmt.Fprintf(buffer, "%s %d %d\n", g, lastValue, now)
num++
default:
continue
}
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.
also i'm thinking that s/trackedGauges/lastGaugeValue
might be a better variable name.
4b969a6
to
69f5e72
Compare
69f5e72
to
5161668
Compare
Thanks for the tips, modified per comments. |
add delete-gauges flag to support re-sending a value when there was no u...
This is adding a flag for a config option that statsd normally supports:
https://github.com/etsy/statsd/blob/master/docs/metric_types.md#gauges