func createAll()

in sample-apps/prometheus-sample-app/metrics/metrics_cli.go [147:183]


func createAll(count int, mc metricCollector, isRandom bool) {

	if isRandom {
		idx := rand.Intn(4)
		lower := 1
		upper := 4
		amount := rand.Intn(upper-lower) + lower
		metrics := []string{"counter", "gauge", "histogram", "summary"}
		rands := []int{rand.Intn(200), rand.Intn(200), rand.Intn(200), rand.Intn(200)}
		for i := 0; i <= amount; i++ {
			if idx >= len(metrics) {
				idx = 0
			}
			str := metrics[idx]
			idx++
			switch str {
			case "counter":
				createCounter(rands[0], mc)
			case "gauge":
				createGauge(rands[1], mc)
			case "histogram":
				createHistogram(rands[2], mc)
			case "summary":
				createSummary(rands[3], mc)
			}
		}

	} else {
		mc.registerCounter(count)
		mc.registerGauge(count)
		mc.registerHistogram(count)
		mc.registerSummary(count)
		go mc.updateMetrics()

	}

}