本文整理匯總了Golang中github.com/google/mtail/metrics.Metric.RLock方法的典型用法代碼示例。如果您正苦於以下問題:Golang Metric.RLock方法的具體用法?Golang Metric.RLock怎麽用?Golang Metric.RLock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/google/mtail/metrics.Metric
的用法示例。
在下文中一共展示了Metric.RLock方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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())
}
示例4: 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)
}