summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cf82a74)
raw | patch | inline | side by side (parent: cf82a74)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 14 May 2015 17:22:36 +0000 (19:22 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Thu, 14 May 2015 17:22:36 +0000 (19:22 +0200) |
graph/graph.go | patch | blob | history |
diff --git a/graph/graph.go b/graph/graph.go
index 2209671c9f88c270afc4268ce372ac30204bfbf3..17de57d8e48552d4672d6883e064b68e9c476041 100644 (file)
--- a/graph/graph.go
+++ b/graph/graph.go
import (
"fmt"
+ "sort"
"strings"
"time"
@@ -146,17 +147,23 @@ func (g *Graph) group(c *client.Client, start, end time.Time) ([]Metric, error)
return g.Metrics, nil
}
+ names := make([]string, 0)
groups := make(map[string][]Metric)
for _, m := range g.Metrics {
var key string
for _, g := range g.GroupBy {
key += "\x00" + m.Attributes[g]
}
+ if _, ok := groups[key]; !ok {
+ names = append(names, key)
+ }
groups[key] = append(groups[key], m)
}
+ sort.Strings(names)
var metrics []Metric
- for name, group := range groups {
+ for _, name := range names {
+ group := groups[name]
ts, err := queryTimeseries(c, group[0], g.Start, g.End)
if err != nil {
return nil, err