本文整理汇总了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
}
示例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
}
示例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
}
示例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
}
示例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()),
}
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}