func TestSetMetricsGlobal(t *testing.T) { metrics.IncrementCount("countMetric") // doesn't blow up when no global set tr := TestRecorder{metrics: map[string]interface{}{}} metrics.SetMetricsGlobal(&tr) metrics.IncrementCount("countMetric") if want, have := 1, tr.metrics["countMetric"]; want != have { t.Errorf("want %#v, have %#v", want, have) } metrics.IncrementCountBy("countMetric", 3) if want, have := 4, tr.metrics["countMetric"]; want != have { t.Errorf("want %#v, have %#v", want, have) } }
func TestGetDatadogStatsdMetric(t *testing.T) { dd, _ := metrics.NewDatadogStatsdRecorder("127.0.0.1:8888", "namespace", "hostname") dd.IncrementCount("countMetric") metrics.SetMetricsGlobal(dd) metrics.IncrementCount("countMetric") }
func TestGetStatsdMetric(t *testing.T) { sd, _ := metrics.NewStatsdRecorder("127.0.0.1:8888", "namespace") sd.IncrementCount("countMetric") // doesn't panic metrics.SetMetricsGlobal(sd) metrics.IncrementCount("countMetric") }