diff --git a/engine.go b/engine.go index fe397be..463385d 100644 --- a/engine.go +++ b/engine.go @@ -156,10 +156,20 @@ func (eng *Engine) measure(t time.Time, name string, value interface{}, ftype Fi eng.once.Do(func() { vsn := strings.TrimPrefix(runtime.Version(), "go") parts := strings.Split(vsn, ".") - // this filters out weird compiled Go versions like tip. - // older Go version might be "go1.13" + // this filters out weird compiled Go versions like tip. len(parts) + // may equal 2 because older Go version might be "go1.13" if len(parts) == 2 || len(parts) == 3 { - eng.measureOne(t, "go_version", 1, Gauge, []Tag{{"go_version", vsn}}...) + eng.Handler.HandleMeasures(t, Measure{ + + Name: "go_version", + Fields: []Field{{ + Name: "go_version", + Value: intValue(1), + }}, + Tags: []Tag{ + {"go_version", vsn}, + }, + }) } }) } diff --git a/netstats/listener_test.go b/netstats/listener_test.go index d5d4343..91e82ae 100644 --- a/netstats/listener_test.go +++ b/netstats/listener_test.go @@ -66,11 +66,25 @@ func TestListenerError(t *testing.T) { vsn := strings.TrimPrefix(runtime.Version(), "go") parts := strings.Split(vsn, ".") measures := h.Measures() + measurePassed := false if len(parts) == 2 || len(parts) == 3 { - if len(measures) != 1+1 { - t.Fatalf("expecting to get %d metrics, got back %d: %v", 1+1, len(measures), measures) + for _, measure := range measures { + if measure.Name != "go_version" { + continue + } + for _, tag := range measure.Tags { + if tag.Name != "go_version" { + continue + } + if tag.Value == vsn { + measurePassed = true + } + } } } + if !measurePassed { + t.Errorf("did not find correct tag for measure: %#v\n", measures) + } var foundMetric stats.Measure for i := range measures { if measures[i].Name == "netstats.test.conn.error" {