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


Golang Metric.GetDimensions方法代码示例

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


在下文中一共展示了Metric.GetDimensions方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例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: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: convertToGraphite

func (g *Graphite) convertToGraphite(metric *metric.Metric) string {
	outname := g.Prefix() + (*metric).Name
	dimensions := metric.GetDimensions(g.DefaultDimensions())
	// for key in dimensions, generate a new metric data point, add to a list, return
	//what timestamp to use?

	//orders keys so datapoint keeps consistent name
	var keys []string
	for k := range dimensions {
		keys = append(keys, k)
	}
	sort.Strings(keys)

	for _, key := range keys {
		//create a list of datapoints for this metric, then append that list the a global list
		outname = fmt.Sprintf("%s.%s.%s", outname, key, dimensions[key])
	}

	outname = fmt.Sprintf("%s %f %d", outname, metric.Value, time.Now().Unix())

	return outname
}
开发者ID:chrisenuf,项目名称:fullerite,代码行数:22,代码来源:graphite.go

示例10: serializedDimensions

func (d *Datadog) serializedDimensions(m metric.Metric) (dimensions []string) {
	for name, value := range m.GetDimensions(d.DefaultDimensions()) {
		dimensions = append(dimensions, name+":"+value)
	}
	return dimensions
}
开发者ID:sagar8192,项目名称:fullerite,代码行数:6,代码来源:datadog.go


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