當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。