Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Fixes #1075 - control.FetchMetrics does not return latest metric when…
Browse files Browse the repository at this point in the history
… version is < 0
  • Loading branch information
jcooklin committed Jul 15, 2016
1 parent c787526 commit 78ea8aa
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions control/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -995,13 +995,27 @@ func (p *pluginControl) FetchMetrics(ns core.Namespace, version int) ([]core.Cat
return nil, err
}
cmt := make([]core.CatalogedMetric, 0, len(mts))
nsMap := map[string]struct{}{}
for _, mt := range mts {
if version > 0 {
// a version is specified
if mt.version == version {
cmt = append(cmt, mt)
}
} else if version < 0 {
// -1 (or less) is specified meaning return the latest
if _, ok := nsMap[mt.Namespace().String()]; !ok {
mt, err = p.metricCatalog.Get(mt.Namespace(), version)
if err != nil {
return nil, err
}
cmt = append(cmt, mt)
nsMap[mt.Namespace().String()] = struct{}{}
}
} else {
// no version is specified return all metric versions
cmt = append(cmt, mt)

}
}
return cmt, nil
Expand Down

0 comments on commit 78ea8aa

Please sign in to comment.