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

Commit

Permalink
Merge pull request #809 from danielscottt/tags
Browse files Browse the repository at this point in the history
forward tags and labels from the catalog to the plugin on collection
  • Loading branch information
jcooklin committed Mar 29, 2016
2 parents fb04a73 + 6a3560f commit ed2e620
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions control/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -979,26 +979,32 @@ func (p *pluginMetricTypes) Count() int {
func groupMetricTypesByPlugin(cat catalogsMetrics, metricTypes []core.Metric) (map[string]pluginMetricTypes, serror.SnapError) {
pmts := make(map[string]pluginMetricTypes)
// For each plugin type select a matching available plugin to call
for _, mt := range metricTypes {
version := mt.Version()
for _, incomingmt := range metricTypes {
version := incomingmt.Version()
if version == 0 {
// If the version is not provided we will choose the latest
version = -1
}

lp, err := cat.GetPlugin(mt.Namespace(), version)
catalogedmt, err := cat.Get(incomingmt.Namespace(), version)
if err != nil {
return nil, serror.New(err)
}
// if loaded plugin is nil, we have failed. return error
returnedmt := plugin.PluginMetricType{
Namespace_: incomingmt.Namespace(),
LastAdvertisedTime_: catalogedmt.LastAdvertisedTime(),
Version_: incomingmt.Version(),
Tags_: catalogedmt.Tags(),
Labels_: catalogedmt.Labels(),
Config_: incomingmt.Config(),
}
lp := catalogedmt.Plugin
if lp == nil {
return nil, serror.New(errorMetricNotFound(mt.Namespace()))
return nil, serror.New(errorMetricNotFound(incomingmt.Namespace()))
}

key := lp.Key()
pmt, _ := pmts[key]
pmt.plugin = lp
pmt.metricTypes = append(pmt.metricTypes, mt)
pmt.metricTypes = append(pmt.metricTypes, returnedmt)
pmts[key] = pmt
}
return pmts, nil
Expand Down

0 comments on commit ed2e620

Please sign in to comment.