Skip to content

Commit

Permalink
fix behaviour of Gauge: it used to behave like GaugeDelta when passed…
Browse files Browse the repository at this point in the history
… a positive value
  • Loading branch information
quipo committed Dec 11, 2017
1 parent 5d0a911 commit 977fadb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ The string `%HOST%` in the metric name will automatically be replaced with the h

* `HEAD`:

* Fixed behaviour of Gauge with positive numbers: the previous behaviour was the same as GaugeDelta
(FGauge already had the correct behaviour)
* Added more tests
* Small optimisation: replace string formatting with concatenation (thanks to @agnivade)

Expand Down
2 changes: 1 addition & 1 deletion event/gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (e Gauge) Stats() []string {
fmt.Sprintf("%s:%d|g", e.Name, e.Value),
}
}
return []string{fmt.Sprintf("%s:%+d|g", e.Name, e.Value)}
return []string{fmt.Sprintf("%s:%d|g", e.Name, e.Value)}
}

// Key returns the name of this metric
Expand Down
2 changes: 1 addition & 1 deletion event/gauge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestGaugeUpdate(t *testing.T) {
t.Error(err)
}

expected := []string{"test:+8|g"} // only the last value is flushed
expected := []string{"test:8|g"} // only the last value is flushed
actual := e1.Stats()
if !reflect.DeepEqual(expected, actual) {
t.Errorf("did not receive all metrics: Expected: %T %v, Actual: %T %v ", expected, expected, actual, actual)
Expand Down

0 comments on commit 977fadb

Please sign in to comment.