diff --git a/agent/reader.go b/agent/reader.go index 7c9639a..9e86656 100644 --- a/agent/reader.go +++ b/agent/reader.go @@ -3,6 +3,7 @@ package agent import ( "fmt" "log" + "sort" "strings" "sync" "time" @@ -69,11 +70,17 @@ func read(queue chan *types.Sample) { func postSeries(series []*prompb.TimeSeries) { if config.Config.TestMode { + log.Println(">> count:", len(series)) + for i := 0; i < len(series); i++ { var sb strings.Builder sb.WriteString(">> ") + sort.SliceStable(series[i].Labels, func(x, y int) bool { + return strings.Compare(series[i].Labels[x].Name, series[i].Labels[y].Name) == -1 + }) + for j := range series[i].Labels { sb.WriteString(series[i].Labels[j].Name) sb.WriteString("=") @@ -100,6 +107,7 @@ func postSeries(series []*prompb.TimeSeries) { writer.Writers[key].Write(series) }(key) } + wg.Wait() } func convert(item *types.Sample) *prompb.TimeSeries {