本文整理汇总了Golang中fullerite/metric.Metric.AddDimension方法的典型用法代码示例。如果您正苦于以下问题:Golang Metric.AddDimension方法的具体用法?Golang Metric.AddDimension怎么用?Golang Metric.AddDimension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fullerite/metric.Metric
的用法示例。
在下文中一共展示了Metric.AddDimension方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: addDimensionsFromName
func addDimensionsFromName(m *metric.Metric, dimensions []string) {
var dimension []string
for i := 1; i < len(dimensions); i++ {
dimension = strings.Split(dimensions[i], "=")
m.AddDimension(dimension[0], dimension[1])
}
}
示例2: Collect
// Collect reads metrics collected from Diamond collectors, converts
// them to fullerite's Metric type and publishes them to handlers.
func (d Diamond) Collect() {
for line := range d.incoming {
var metric metric.Metric
if err := json.Unmarshal(line, &metric); err != nil {
log.Error("Cannot unmarshal metric line from diamond:", line)
continue
}
metric.AddDimension("diamond", "yes")
d.Channel() <- metric
}
}
示例3: parseMetric
func (d *Diamond) parseMetric(line []byte) (metric.Metric, bool) {
var metric metric.Metric
if err := json.Unmarshal(line, &metric); err != nil {
d.log.Error("Cannot unmarshal metric line from diamond:", line)
return metric, false
}
// All diamond metric_types are reported in uppercase, lets make them
// fullerite compatible
metric.MetricType = strings.ToLower(metric.MetricType)
metric.AddDimension("diamond", "yes")
return metric, true
}
示例4: Collect
// Collect reads metrics collected from Diamond collectors, converts
// them to fullerite's Metric type and publishes them to handlers.
func (d *Diamond) Collect() {
if !d.serverStarted {
d.serverStarted = true
go d.collectDiamond()
}
for line := range d.incoming {
var metric metric.Metric
if err := json.Unmarshal(line, &metric); err != nil {
d.log.Error("Cannot unmarshal metric line from diamond:", line)
continue
}
metric.AddDimension("diamond", "yes")
d.Channel() <- metric
}
}