diff --git a/go.mod b/go.mod index f2fbaf5..623cac0 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,3 @@ module github.com/Netflix/spectator-go go 1.21 - -require ( - github.com/json-iterator/go v1.1.12 - github.com/klauspost/compress v1.15.12 - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/pkg/errors v0.9.1 - golang.org/x/sync v0.1.0 -) diff --git a/go.sum b/go.sum index 0b62498..e69de29 100644 --- a/go.sum +++ b/go.sum @@ -1,22 +0,0 @@ -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/klauspost/compress v1.15.12 h1:YClS/PImqYbn+UILDnqxQCZ3RehC9N318SU3kElDUEM= -github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/spectator/meter/age_gauge.go b/spectator/meter/age_gauge.go index e6fdc55..fcbe52d 100644 --- a/spectator/meter/age_gauge.go +++ b/spectator/meter/age_gauge.go @@ -29,11 +29,9 @@ func (g *AgeGauge) MeterId() *Id { } // Set records the current value. -func (g *AgeGauge) Set(value int64) { - if value >= 0 { - var line = fmt.Sprintf("%s:%s:%d", g.meterTypeSymbol, g.id.spectatordId, value) - g.writer.Write(line) - } +func (g *AgeGauge) Set(value uint64) { + var line = fmt.Sprintf("%s:%s:%d", g.meterTypeSymbol, g.id.spectatordId, value) + g.writer.Write(line) } // Now records the current time in epoch seconds in spectatord. diff --git a/spectator/meter/age_gauge_test.go b/spectator/meter/age_gauge_test.go index aa29fbf..1b3c2a2 100644 --- a/spectator/meter/age_gauge_test.go +++ b/spectator/meter/age_gauge_test.go @@ -41,17 +41,6 @@ func TestAgeGauge_Now(t *testing.T) { } } -func TestAgeGauge_SetNegative(t *testing.T) { - id := NewId("setNegative", nil) - w := writer.MemoryWriter{} - g := NewAgeGauge(id, &w) - g.Set(-100) - - if len(w.Lines) != 0 { - t.Error("Negative values should be ignored") - } -} - func TestAgeGauge_SetMultipleValues(t *testing.T) { id := NewId("setMultiple", nil) w := writer.MemoryWriter{} diff --git a/spectator/meter/counter.go b/spectator/meter/counter.go index a5124b3..1488983 100644 --- a/spectator/meter/counter.go +++ b/spectator/meter/counter.go @@ -42,10 +42,8 @@ func (c *Counter) AddFloat(delta float64) { } } -// Add is to add a specific int64 delta to the current measurement. -func (c *Counter) Add(delta int64) { - if delta > 0 { - var line = fmt.Sprintf("%s:%s:%d", c.meterTypeSymbol, c.id.spectatordId, delta) - c.writer.Write(line) - } +// Add is to add a specific uint64 delta to the current measurement. +func (c *Counter) Add(delta uint64) { + var line = fmt.Sprintf("%s:%s:%d", c.meterTypeSymbol, c.id.spectatordId, delta) + c.writer.Write(line) } diff --git a/spectator/meter/counter_test.go b/spectator/meter/counter_test.go index 0afb0dc..f37f564 100644 --- a/spectator/meter/counter_test.go +++ b/spectator/meter/counter_test.go @@ -47,9 +47,4 @@ func TestCounter_Add(t *testing.T) { if w.Lines[0] != expected { t.Error("Expected ", expected, " got ", w.Lines[0]) } - - c.Add(-1) - if len(w.Lines) != 1 { - t.Error("Negative deltas should be ignored") - } } diff --git a/spectator/meter/dist_summary.go b/spectator/meter/dist_summary.go index 414dc32..33c420b 100644 --- a/spectator/meter/dist_summary.go +++ b/spectator/meter/dist_summary.go @@ -30,9 +30,7 @@ func (d *DistributionSummary) MeterId() *Id { } // Record records a new value to track within the distribution. -func (d *DistributionSummary) Record(amount int64) { - if amount >= 0 { - var line = fmt.Sprintf("%s:%s:%d", d.meterTypeSymbol, d.id.spectatordId, amount) - d.writer.Write(line) - } +func (d *DistributionSummary) Record(amount uint64) { + var line = fmt.Sprintf("%s:%s:%d", d.meterTypeSymbol, d.id.spectatordId, amount) + d.writer.Write(line) } diff --git a/spectator/meter/dist_summary_test.go b/spectator/meter/dist_summary_test.go index 6b7df63..bbad567 100644 --- a/spectator/meter/dist_summary_test.go +++ b/spectator/meter/dist_summary_test.go @@ -29,17 +29,6 @@ func TestDistributionSummary_RecordZeroValue(t *testing.T) { } } -func TestDistributionSummary_RecordNegativeValue(t *testing.T) { - id := NewId("recordNegative", nil) - w := writer.MemoryWriter{} - ds := NewDistributionSummary(id, &w) - ds.Record(-100) - - if len(w.Lines) != 0 { - t.Errorf("Expected no lines, got %d", len(w.Lines)) - } -} - func TestDistributionSummary_RecordMultipleValues(t *testing.T) { id := NewId("recordMultiple", nil) w := writer.MemoryWriter{} diff --git a/spectator/meter/monotonic_counter.go b/spectator/meter/monotonic_counter.go index 1c9a03a..b55077d 100644 --- a/spectator/meter/monotonic_counter.go +++ b/spectator/meter/monotonic_counter.go @@ -29,10 +29,8 @@ func (c *MonotonicCounter) MeterId() *Id { return c.id } -// Set is to set a specific int64 delta as the current measurement. -func (c *MonotonicCounter) Set(delta int64) { - if delta > 0 { - var line = fmt.Sprintf("%s:%s:%d", c.meterTypeSymbol, c.id.spectatordId, delta) - c.writer.Write(line) - } +// Set is to set a specific uint64 value as the current measurement - spectatord will calculate the delta. +func (c *MonotonicCounter) Set(value uint64) { + var line = fmt.Sprintf("%s:%s:%d", c.meterTypeSymbol, c.id.spectatordId, value) + c.writer.Write(line) } diff --git a/spectator/meter/monotonic_counter_test.go b/spectator/meter/monotonic_counter_test.go index e4ddb7f..4bf890f 100644 --- a/spectator/meter/monotonic_counter_test.go +++ b/spectator/meter/monotonic_counter_test.go @@ -16,9 +16,4 @@ func TestMonotonicCounter_Set(t *testing.T) { if w.Lines[0] != expected { t.Error("Expected ", expected, " got ", w.Lines[0]) } - - c.Set(-1) - if len(w.Lines) != 1 { - t.Error("Negative deltas should be ignored") - } } diff --git a/spectator/meter/percentile_distsummary.go b/spectator/meter/percentile_distsummary.go index ef99659..6123a32 100644 --- a/spectator/meter/percentile_distsummary.go +++ b/spectator/meter/percentile_distsummary.go @@ -23,9 +23,7 @@ func NewPercentileDistributionSummary(id *Id, writer writer.Writer) *PercentileD } // Record records a new value to track within the distribution. -func (p *PercentileDistributionSummary) Record(amount int64) { - if amount >= 0 { - var line = fmt.Sprintf("%s:%s:%d", p.meterTypeSymbol, p.id.spectatordId, amount) - p.writer.Write(line) - } +func (p *PercentileDistributionSummary) Record(amount uint64) { + var line = fmt.Sprintf("%s:%s:%d", p.meterTypeSymbol, p.id.spectatordId, amount) + p.writer.Write(line) } diff --git a/spectator/meter/percentile_distsummary_test.go b/spectator/meter/percentile_distsummary_test.go index a070926..82542bd 100644 --- a/spectator/meter/percentile_distsummary_test.go +++ b/spectator/meter/percentile_distsummary_test.go @@ -34,17 +34,6 @@ func TestPercentileDistributionSummary_RecordZero(t *testing.T) { } } -func TestPercentileDistributionSummary_RecordNegative(t *testing.T) { - id := NewId("recordPercentileNegative", nil) - w := writer.MemoryWriter{} - ds := NewPercentileDistributionSummary(id, &w) - ds.Record(-100) - - if len(w.Lines) != 0 { - t.Errorf("Expected no lines to be written, got %d", len(w.Lines)) - } -} - func TestPercentileDistributionSummary_RecordMultipleValues(t *testing.T) { id := NewId("recordPercentileMultiple", nil) w := writer.MemoryWriter{}