summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/prometheus/client_golang/prometheus/go_collector_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/prometheus/client_golang/prometheus/go_collector_test.go')
-rw-r--r--vendor/github.com/prometheus/client_golang/prometheus/go_collector_test.go51
1 files changed, 24 insertions, 27 deletions
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/go_collector_test.go b/vendor/github.com/prometheus/client_golang/prometheus/go_collector_test.go
index 59dabc09c..9a8858cbd 100644
--- a/vendor/github.com/prometheus/client_golang/prometheus/go_collector_test.go
+++ b/vendor/github.com/prometheus/client_golang/prometheus/go_collector_test.go
@@ -29,36 +29,33 @@ func TestGoCollector(t *testing.T) {
for {
select {
- case m := <-ch:
- // m can be Gauge or Counter,
- // currently just test the go_goroutines Gauge
- // and ignore others.
- if m.Desc().fqName != "go_goroutines" {
- continue
- }
- pb := &dto.Metric{}
- m.Write(pb)
- if pb.GetGauge() == nil {
- continue
- }
+ case metric := <-ch:
+ switch m := metric.(type) {
+ // Attention, this also catches Counter...
+ case Gauge:
+ pb := &dto.Metric{}
+ m.Write(pb)
+ if pb.GetGauge() == nil {
+ continue
+ }
- if old == -1 {
- old = int(pb.GetGauge().GetValue())
- close(waitc)
- continue
- }
+ if old == -1 {
+ old = int(pb.GetGauge().GetValue())
+ close(waitc)
+ continue
+ }
- if diff := int(pb.GetGauge().GetValue()) - old; diff != 1 {
- // TODO: This is flaky in highly concurrent situations.
- t.Errorf("want 1 new goroutine, got %d", diff)
- }
+ if diff := int(pb.GetGauge().GetValue()) - old; diff != 1 {
+ // TODO: This is flaky in highly concurrent situations.
+ t.Errorf("want 1 new goroutine, got %d", diff)
+ }
- // GoCollector performs three sends per call.
- // On line 27 we need to receive the second send
- // to shut down cleanly.
- <-ch
- <-ch
- return
+ // GoCollector performs two sends per call.
+ // On line 27 we need to receive the second send
+ // to shut down cleanly.
+ <-ch
+ return
+ }
case <-time.After(1 * time.Second):
t.Fatalf("expected collect timed out")
}