Esempio n. 1
0
func SaveAllGuesses(name string) {
	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 _, data := range sampleMap {
		g.Space.Graph.Metrics = append(g.Space.Graph.Metrics, GuessMetric{
			ID:         seq[row] + seq[col],
			ReadableID: seq[row] + seq[col],
			Name:       "histogram",
			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++
		}
	}
	SaveGuess(g, "json_metrics/"+names.Arch(name))
}
Esempio n. 2
0
// have to pass in name because metrics.Histogram blocks expvar.Historgram.Name()
func SaveHist(h metrics.Histogram, name, suffix string) {
	if archaius.Conf.Collect {
		file, err := os.Create("csv_metrics/" + names.Arch(name) + "_" + names.Machine(name) + suffix + ".csv")
		if err != nil {
			log.Printf("%v: %v\n", name, err)
		}
		metrics.PrintDistribution(file, h)
		file.Close()
		//Sample data is written out by SaveAllGuesses now
		//dfile, err := os.Create("csv_metrics/" + names.Arch(name) + "_" + names.Machine(name) + suffix + ".data")
		//if err != nil {
		//	log.Printf("%v: %v\n", name, err)
		//}
		//sj, _ := json.Marshal(sampleMap[h])
		//dfile.WriteString(fmt.Sprintf("%v", string(sj)))
		//dfile.Close()
	}
}