当前位置: 首页>>代码示例>>Golang>>正文


Golang metric.Metric类代码示例

本文整理汇总了Golang中fullerite/metric.Metric的典型用法代码示例。如果您正苦于以下问题:Golang Metric类的具体用法?Golang Metric怎么用?Golang Metric使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Metric类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: convertToProto

func (s *SignalFx) convertToProto(incomingMetric *metric.Metric) *DataPoint {
	outname := s.Prefix() + incomingMetric.Name

	datapoint := new(DataPoint)
	datapoint.Metric = &outname
	datapoint.Value = &Datum{
		DoubleValue: &incomingMetric.Value,
	}
	datapoint.Source = new(string)
	*datapoint.Source = "fullerite"

	switch incomingMetric.MetricType {
	case metric.Gauge:
		datapoint.MetricType = MetricType_GAUGE.Enum()
	case metric.Counter:
		datapoint.MetricType = MetricType_COUNTER.Enum()
	case metric.CumulativeCounter:
		datapoint.MetricType = MetricType_CUMULATIVE_COUNTER.Enum()
	}

	dimensions := incomingMetric.GetDimensions(s.DefaultDimensions())
	for key, value := range dimensions {
		dim := Dimension{
			Key:   &key,
			Value: &value,
		}
		datapoint.Dimensions = append(datapoint.Dimensions, &dim)
	}

	return datapoint
}
开发者ID:jaxxstorm,项目名称:fullerite,代码行数:31,代码来源:signalfx.go

示例2: 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])
	}

}
开发者ID:Yelp,项目名称:fullerite,代码行数:8,代码来源:java_metric.go

示例3: getSanitizedDimensions

func (g Graphite) getSanitizedDimensions(incomingMetric metric.Metric) map[string]string {
	dimSanitized := make(map[string]string)
	dimensions := incomingMetric.GetDimensions(g.DefaultDimensions())
	for key, value := range dimensions {
		dimSanitized[graphiteSanitize(key)] = graphiteSanitize(value)
	}
	return dimSanitized
}
开发者ID:EvanKrall,项目名称:fullerite,代码行数:8,代码来源:graphite.go

示例4: getSanitizedDimensions

func (s SignalFx) getSanitizedDimensions(incomingMetric metric.Metric) map[string]string {
	dimSanitized := make(map[string]string)
	dimensions := incomingMetric.GetDimensions(s.DefaultDimensions())
	for key, value := range dimensions {
		dimSanitized[signalFxKeySanitize(key)] = signalFxValueSanitize(value)
	}
	return dimSanitized
}
开发者ID:EvanKrall,项目名称:fullerite,代码行数:8,代码来源:signalfx.go

示例5: convertToKairos

func (k Kairos) convertToKairos(incomingMetric metric.Metric) (datapoint KairosMetric) {
	km := new(KairosMetric)
	km.Name = k.Prefix() + incomingMetric.Name
	km.Value = incomingMetric.Value
	km.MetricType = "double"
	km.Timestamp = time.Now().Unix() * 1000 // Kairos require timestamps to be milliseconds
	km.Tags = incomingMetric.GetDimensions(k.DefaultDimensions())
	return *km
}
开发者ID:venkey-ariv,项目名称:fullerite,代码行数:9,代码来源:kairos.go

示例6: createScribeMetric

func (s *Scribe) createScribeMetric(m metric.Metric) scribeMetric {
	return scribeMetric{
		Name:       m.Name,
		Value:      m.Value,
		MetricType: m.MetricType,
		Timestamp:  time.Now().Unix(),
		Dimensions: m.GetDimensions(s.DefaultDimensions()),
	}

}
开发者ID:sagar8192,项目名称:fullerite,代码行数:10,代码来源:scribe.go

示例7: 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
	}
}
开发者ID:chrisenuf,项目名称:fullerite,代码行数:13,代码来源:diamond.go

示例8: 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
}
开发者ID:gsalisbury,项目名称:fullerite,代码行数:12,代码来源:diamond.go

示例9: convertToKairos

func (k Kairos) convertToKairos(incomingMetric metric.Metric) (datapoint KairosMetric) {
	km := new(KairosMetric)
	km.Name = k.Prefix() + kairosSanitize(incomingMetric.Name)
	km.Value = incomingMetric.Value
	km.MetricType = "double"
	km.Timestamp = time.Now().Unix() * 1000 // Kairos require timestamps to be milliseconds
	km.Tags = make(map[string]string)
	for key, value := range incomingMetric.GetDimensions(k.DefaultDimensions()) {
		km.Tags[kairosSanitize(key)] = kairosSanitize(value)
	}
	return *km
}
开发者ID:EvanKrall,项目名称:fullerite,代码行数:12,代码来源:kairos.go

示例10: convertToDatadog

func (d *Datadog) convertToDatadog(incomingMetric metric.Metric) (datapoint datadogMetric) {
	dog := new(datadogMetric)
	dog.Metric = incomingMetric.Name
	dog.Points = makeDatadogPoints(incomingMetric)
	dog.MetricType = incomingMetric.MetricType
	if host, ok := incomingMetric.GetDimensionValue("host", d.DefaultDimensions()); ok {
		dog.Host = host
	} else {
		dog.Host = "unknown"
	}
	dog.Tags = d.serializedDimensions(incomingMetric)
	return *dog
}
开发者ID:jaxxstorm,项目名称:fullerite,代码行数:13,代码来源:datadog.go

示例11: 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
	}
}
开发者ID:jp2007,项目名称:fullerite,代码行数:18,代码来源:diamond.go

示例12: convertToGraphite

func (g *Graphite) convertToGraphite(incomingMetric metric.Metric) (datapoint string) {
	//orders dimensions so datapoint keeps consistent name
	var keys []string
	dimensions := incomingMetric.GetDimensions(g.DefaultDimensions())
	for k := range dimensions {
		keys = append(keys, k)
	}
	sort.Strings(keys)

	datapoint = g.Prefix() + incomingMetric.Name
	for _, key := range keys {
		datapoint = fmt.Sprintf("%s.%s.%s", datapoint, key, dimensions[key])
	}
	datapoint = fmt.Sprintf("%s %f %d\n", datapoint, incomingMetric.Value, time.Now().Unix())
	return datapoint
}
开发者ID:jaxxstorm,项目名称:fullerite,代码行数:16,代码来源:graphite.go

示例13: convertToProto

func (s SignalFx) convertToProto(incomingMetric metric.Metric) *DataPoint {
	// Create a new values for the Datapoint that requires pointers.
	outname := s.Prefix() + incomingMetric.Name
	value := incomingMetric.Value

	now := time.Now().UnixNano() / int64(time.Millisecond)
	datapoint := new(DataPoint)
	datapoint.Timestamp = &now
	datapoint.Metric = &outname
	datapoint.Value = &Datum{
		DoubleValue: &value,
	}
	datapoint.Source = new(string)
	*datapoint.Source = "fullerite"

	switch incomingMetric.MetricType {
	case metric.Gauge:
		datapoint.MetricType = MetricType_GAUGE.Enum()
	case metric.Counter:
		datapoint.MetricType = MetricType_COUNTER.Enum()
	case metric.CumulativeCounter:
		datapoint.MetricType = MetricType_CUMULATIVE_COUNTER.Enum()
	}

	dimensions := incomingMetric.GetDimensions(s.DefaultDimensions())
	for key, value := range dimensions {
		// Dimension (protobuf) require a pointer to string
		// values. We need to create new string objects in the
		// scope of this for loop not to repeatedly add the
		// same key:value pairs to the the datapoint.
		dimensionKey := key
		dimensionValue := value
		dim := Dimension{
			Key:   &dimensionKey,
			Value: &dimensionValue,
		}
		datapoint.Dimensions = append(datapoint.Dimensions, &dim)
	}

	return datapoint
}
开发者ID:venkey-ariv,项目名称:fullerite,代码行数:41,代码来源:signalfx.go

示例14: writeToHandlers

func writeToHandlers(handlers []handler.Handler, metric metric.Metric) {
	for _, handler := range handlers {
		value, ok := metric.GetDimensionValue("collector")
		isBlackListed, _ := handler.IsCollectorBlackListed(value)
		if ok && isBlackListed {
			// This collector is black listed by
			// this handler. Therefore we are dropping this
			log.Debug("Not forwarding metrics from", value, "collector to", handler.Name(), "handler, since it has blacklisted this collector")
		} else {
			handler.Channel() <- metric
		}
	}
}
开发者ID:anthonygtellez,项目名称:fullerite,代码行数:13,代码来源:handlers.go

示例15: Collect

// Collect calls smem periodically
func (s *SmemStats) Collect() {
	if s.whitelistedProcs == "" || s.user == "" || s.smemPath == "" {
		return
	}

	for _, stat := range getSmemStats(s) {
		dims := s.getCustomDimensions(stat.pid)
		for _, element := range s.whitelistedMetrics {
			var m metric.Metric
			switch element {
			case "pss":
				m = metric.WithValue(stat.proc+".smem.pss", stat.pss)
			case "uss":
				m = metric.WithValue(stat.proc+".smem.uss", stat.uss)
			case "vss":
				m = metric.WithValue(stat.proc+".smem.vss", stat.vss)
			case "rss":
				m = metric.WithValue(stat.proc+".smem.rss", stat.rss)
			}
			m.AddDimensions(dims)
			s.Channel() <- m
		}
	}
}
开发者ID:Yelp,项目名称:fullerite,代码行数:25,代码来源:smem.go


注:本文中的fullerite/metric.Metric类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。