From 4d8e1b9eb92b797a8609edd2395afd84f64deb7f Mon Sep 17 00:00:00 2001 From: zeim839 Date: Tue, 14 May 2024 10:16:55 -0400 Subject: [PATCH] fix: update test values for synchronous EWMA --- graphite/graphite_test.go | 6 +++--- logging/encode_test.go | 12 ++++++------ prometheus/prometheus_test.go | 6 +++--- statsd/statsd_test.go | 26 +++----------------------- 4 files changed, 15 insertions(+), 35 deletions(-) diff --git a/graphite/graphite_test.go b/graphite/graphite_test.go index 3b54643..a5edf1b 100644 --- a/graphite/graphite_test.go +++ b/graphite/graphite_test.go @@ -89,17 +89,17 @@ func TestWrites(t *testing.T) { t.Errorf("%s != %s", expect, str[:len(str)-12]) } - expect = "p.bar.rate.15min 1.000000" + expect = "p.bar.rate.15min 0.000000" if str := res["p.bar.rate.15min"]; expect != str[:len(str)-12] { t.Errorf("%s != %s", expect, str[:len(str)-12]) } - expect = "p.bar.rate.1min 1.000000" + expect = "p.bar.rate.1min 0.000000" if str := res["p.bar.rate.1min"]; expect != str[:len(str)-12] { t.Errorf("%s != %s", expect, str[:len(str)-12]) } - expect = "p.bar.rate.5min 1.000000" + expect = "p.bar.rate.5min 0.000000" if str := res["p.bar.rate.5min"]; expect != str[:len(str)-12] { t.Errorf("%s != %s", expect, str[:len(str)-12]) } diff --git a/logging/encode_test.go b/logging/encode_test.go index 891c65e..012dbca 100644 --- a/logging/encode_test.go +++ b/logging/encode_test.go @@ -298,15 +298,15 @@ func TestEncodeMeter(t *testing.T) { if line := lines[0][:len(lines[0])-11]; line != expect { t.Errorf("Encode(): %s != %s", line, expect) } - expect = "bar_foo_rate_1min 20.000000" + expect = "bar_foo_rate_1min 0.000000" if line := lines[1][:len(lines[1])-11]; line != expect { t.Errorf("Encode(): %s != %s", line, expect) } - expect = "bar_foo_rate_5min 20.000000" + expect = "bar_foo_rate_5min 0.000000" if line := lines[2][:len(lines[2])-11]; line != expect { t.Errorf("Encode(): %s != %s", line, expect) } - expect = "bar_foo_rate_15min 20.000000" + expect = "bar_foo_rate_15min 0.000000" if line := lines[3][:len(lines[3])-11]; line != expect { t.Errorf("Encode(): %s != %s", line, expect) } @@ -326,15 +326,15 @@ func TestEncodeMeter(t *testing.T) { if line := lines[0][:len(lines[0])-11]; line != expect { t.Errorf("Encode(): %s != %s", line, expect) } - expect = "foo_rate_1min 20.000000" + expect = "foo_rate_1min 0.000000" if line := lines[1][:len(lines[1])-11]; line != expect { t.Errorf("Encode(): %s != %s", line, expect) } - expect = "foo_rate_5min 20.000000" + expect = "foo_rate_5min 0.000000" if line := lines[2][:len(lines[2])-11]; line != expect { t.Errorf("Encode(): %s != %s", line, expect) } - expect = "foo_rate_15min 20.000000" + expect = "foo_rate_15min 0.000000" if line := lines[3][:len(lines[3])-11]; line != expect { t.Errorf("Encode(): %s != %s", line, expect) } diff --git a/prometheus/prometheus_test.go b/prometheus/prometheus_test.go index 6d61b05..d6c0052 100644 --- a/prometheus/prometheus_test.go +++ b/prometheus/prometheus_test.go @@ -128,19 +128,19 @@ func TestPrometheusOnce(t *testing.T) { } expected = "name:\"meter_rate_15min\" help:\"meter_rate_15min\" type:GAUGE " + - "metric: > " + "metric: > " if expected != fmt.Sprint(metrics[3]) { t.Errorf("Once(): %s != %s", expected, metrics[3]) } expected = "name:\"meter_rate_1min\" help:\"meter_rate_1min\" type:GAUGE " + - "metric: > " + "metric: > " if expected != fmt.Sprint(metrics[4]) { t.Errorf("Once(): %s != %s", expected, metrics[4]) } expected = "name:\"meter_rate_5min\" help:\"meter_rate_5min\" type:GAUGE " + - "metric: > " + "metric: > " if expected != fmt.Sprint(metrics[5]) { t.Errorf("Once(): %s != %s", expected, metrics[5]) } diff --git a/statsd/statsd_test.go b/statsd/statsd_test.go index 6586065..cf147bd 100644 --- a/statsd/statsd_test.go +++ b/statsd/statsd_test.go @@ -73,7 +73,7 @@ func TestWrites(t *testing.T) { defer ln.Close() metrics.GetOrRegisterCounter("foo", nil).Inc(2) - metrics.GetOrRegisterMeter("bar", nil).Mark(1) + metrics.GetOrRegisterGauge("bar", nil).Update(1) ctx.Store(false) wg.Add(1) @@ -84,28 +84,8 @@ func TestWrites(t *testing.T) { } wg.Wait() - expect := "p.bar.count:1|c\n" - if str := res["p.bar.count"]; expect != str { - t.Errorf("%v != %v", expect, str) - } - - expect = "p.bar.rate.15min:1.000000|g\n" - if str := res["p.bar.rate.15min"]; expect != str { - t.Errorf("%v != %v", expect, str) - } - - expect = "p.bar.rate.5min:1.000000|g\n" - if str := res["p.bar.rate.5min"]; expect != str { - t.Errorf("%v != %v", expect, str) - } - - expect = "p.bar.rate.1min:1.000000|g\n" - if str := res["p.bar.rate.1min"]; expect != str { - t.Errorf("%v != %v", expect, str) - } - - expect = "p.bar.rate.1min:1.000000|g\n" - if str := res["p.bar.rate.1min"]; expect != str { + expect := "p.bar:1|g\n" + if str := res["p.bar"]; expect != str { t.Errorf("%v != %v", expect, str) }