本文整理汇总了Golang中github.com/google/mtail/metrics.Metric类的典型用法代码示例。如果您正苦于以下问题:Golang Metric类的具体用法?Golang Metric怎么用?Golang Metric使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Metric类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: metricToGraphite
func metricToGraphite(hostname string, m *metrics.Metric, l *metrics.LabelSet) string {
m.RLock()
defer m.RUnlock()
return fmt.Sprintf("%s.%s %v %v\n",
m.Program,
formatLabels(m.Name, l.Labels, ".", "."),
l.Datum.Get(),
l.Datum.Time/1e9)
}
示例2: metricToStatsd
func metricToStatsd(hostname string, m *metrics.Metric, l *metrics.LabelSet) string {
// TODO(jaq): handle units better, send timing as |ms
m.RLock()
defer m.RUnlock()
return fmt.Sprintf("%s.%s:%d|c",
m.Program,
formatLabels(m.Name, l.Labels, ".", "."),
l.Datum.Get())
}
示例3: FakeSocketWrite
func FakeSocketWrite(f formatter, m *metrics.Metric) []string {
var ret []string
lc := make(chan *metrics.LabelSet)
go m.EmitLabelSets(lc)
for l := range lc {
ret = append(ret, f("gunstar", m, l))
}
sort.Strings(ret)
return ret
}
示例4: metricToCollectd
func metricToCollectd(hostname string, m *metrics.Metric, l *metrics.LabelSet) string {
m.RLock()
defer m.RUnlock()
return fmt.Sprintf(collectdFormat,
hostname,
m.Program,
strings.ToLower(m.Kind.String()),
formatLabels(m.Name, l.Labels, "-", "-"),
*pushInterval,
l.Datum.Time/1e9,
l.Datum.Get())
}
示例5: metricToStatsd
func metricToStatsd(hostname string, m *metrics.Metric, l *metrics.LabelSet) string {
m.RLock()
defer m.RUnlock()
var t string
switch m.Kind {
case metrics.Counter:
t = "c" // StatsD Counter
case metrics.Gauge:
t = "g" // StatsD Gauge
case metrics.Timer:
t = "ms" // StatsD Timer
}
return fmt.Sprintf("%s.%s:%d|%s",
m.Program,
formatLabels(m.Name, l.Labels, ".", "."),
l.Datum.Get(), t)
}