Exemple #1
0
func TestTimingSampled(t *testing.T) {
	prefix, name := "statsd.", "sampled_timing_test"
	label, value := "foo", "bar" // ignored
	regex := `^` + prefix + name + `:([0-9\.]+)\|ms\|@0\.01[0]*$`
	s := New(prefix, log.NewNopLogger())
	timing := s.NewTiming(name, 0.01).With(label, value)
	quantiles := teststat.Quantiles(s, regex, 50)
	if err := teststat.TestHistogram(timing, quantiles, 0.02); err != nil {
		t.Fatal(err)
	}
}
Exemple #2
0
func TestTiming(t *testing.T) {
	prefix, name := "statsd.", "timing_test"
	label, value := "abc", "def" // ignored
	regex := `^` + prefix + name + `:([0-9\.]+)\|ms$`
	s := New(prefix, log.NewNopLogger())
	timing := s.NewTiming(name, 1.0).With(label, value)
	quantiles := teststat.Quantiles(s, regex, 50) // no |@0.X
	if err := teststat.TestHistogram(timing, quantiles, 0.01); err != nil {
		t.Fatal(err)
	}
}