Beispiel #1
0
func SaveAllGuesses(name string) {
	if len(sampleMap) == 0 {
		return
	}
	log.Printf("Saving %v histograms for Guesstimate\n", len(sampleMap))
	var g Guess
	g = Guess{
		Space: GuessModel{
			Name:        names.Arch(name),
			Description: "Guesstimate generated by github.com/adrianco/spigo",
			IsPrivate:   "true",
			Graph: GuessGraph{
				Metrics:      make([]GuessMetric, 0, len(sampleMap)),
				Guesstimates: make([]Guesstimate, 0, len(sampleMap)),
			},
		},
	}
	row := 1
	col := 1
	seq := []string{"", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
	for h, data := range sampleMap {
		g.Space.Graph.Metrics = append(g.Space.Graph.Metrics, GuessMetric{
			ID:         seq[row] + seq[col],
			ReadableID: seq[row] + seq[col],
			Name:       h.Name(),
			Location:   GuessMetricLocation{row, col},
		})
		g.Space.Graph.Guesstimates = append(g.Space.Graph.Guesstimates, Guesstimate{
			Metric:          seq[row] + seq[col],
			Input:           "",
			GuesstimateType: "DATA",
			Data:            data,
		})
		row++
		if row >= len(seq) {
			row = 1
			col++
			if col >= len(seq) {
				break
			}
		}
	}
	SaveGuess(g, "json_metrics/"+names.Arch(name))
}
Beispiel #2
0
// have to pass in name because metrics.Histogram blocks expvar.Histogram.Name()
func SaveHist(h metrics.Histogram, name, suffix string) {
	if archaius.Conf.Collect {
		file, err := os.Create("csv_metrics/" + names.Arch(name) + "_" + names.Instance(name) + suffix + ".csv")
		if err != nil {
			log.Printf("%v: %v\n", name, err)
		}
		metrics.PrintDistribution(file, h)
		file.Close()
	}
}