本文整理汇总了Golang中github.com/intelsdi-x/snap/control/plugin.MetricType.Config方法的典型用法代码示例。如果您正苦于以下问题:Golang MetricType.Config方法的具体用法?Golang MetricType.Config怎么用?Golang MetricType.Config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/intelsdi-x/snap/control/plugin.MetricType
的用法示例。
在下文中一共展示了MetricType.Config方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetMetricConfigItem
// GetMetricConfigItem returns value of configuration item specified by `name` defined in Metrics Config
// Notes: GetMetricConfigItem() will be helpful to access and get configuration item's value in CollectMetrics()
// (Plugin Global Config is merged into Metric Config)
func GetMetricConfigItem(metric plugin.MetricType, name string) (interface{}, error) {
if metric.Config() != nil && len(metric.Config().Table()) > 0 {
if item, ok := metric.Config().Table()[name]; ok {
return getConfigItemValue(item)
}
}
return nil, fmt.Errorf("Cannot find %v in Metrics Config", name)
}
示例2: GetMetricConfigItems
// GetMetricConfigItems returns map to values of multiple configuration items defined in Metric Config and specified in 'names' slice
// Notes: GetMetricConfigItems() will be helpful to access and get multiple configuration items' values in CollectMetrics()
// (Plugin Global Config is merged into Metric Config)
func GetMetricConfigItems(metric plugin.MetricType, names []string) (map[string]interface{}, error) {
result := make(map[string]interface{})
for _, name := range names {
if metric.Config() != nil && len(metric.Config().Table()) > 0 {
item, ok := metric.Config().Table()[name]
if !ok {
return nil, fmt.Errorf("Cannot find %v in Metrics Config", name)
}
val, err := getConfigItemValue(item)
if err != nil {
return nil, err
}
result[name] = val
} else {
return nil, fmt.Errorf("Cannot find %v in Metrics Config", name)
}
}
return result, nil
}