本文整理匯總了Golang中github.com/google/mtail/metrics.Store.ClearMetrics方法的典型用法代碼示例。如果您正苦於以下問題:Golang Store.ClearMetrics方法的具體用法?Golang Store.ClearMetrics怎麽用?Golang Store.ClearMetrics使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/google/mtail/metrics.Store
的用法示例。
在下文中一共展示了Store.ClearMetrics方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestMetricToCollectd
func TestMetricToCollectd(t *testing.T) {
ts, terr := time.Parse("2006/01/02 15:04:05", "2012/07/24 10:14:00")
if terr != nil {
t.Errorf("time parse error: %s", terr)
}
ms := metrics.Store{}
scalarMetric := metrics.NewMetric("foo", "prog", metrics.Counter)
d, _ := scalarMetric.GetDatum()
d.Set(37, ts)
ms.Add(scalarMetric)
r := FakeSocketWrite(metricToCollectd, scalarMetric)
expected := []string{"PUTVAL \"gunstar/mtail-prog/counter-foo\" interval=60 1343124840:37\n"}
diff := pretty.Compare(r, expected)
if len(diff) > 0 {
t.Errorf("String didn't match:\n%s", diff)
}
dimensionedMetric := metrics.NewMetric("bar", "prog", metrics.Gauge, "label")
d, _ = dimensionedMetric.GetDatum("quux")
d.Set(37, ts)
d, _ = dimensionedMetric.GetDatum("snuh")
d.Set(37, ts)
ms.ClearMetrics()
ms.Add(dimensionedMetric)
r = FakeSocketWrite(metricToCollectd, dimensionedMetric)
expected = []string{
"PUTVAL \"gunstar/mtail-prog/gauge-bar-label-quux\" interval=60 1343124840:37\n",
"PUTVAL \"gunstar/mtail-prog/gauge-bar-label-snuh\" interval=60 1343124840:37\n"}
diff = pretty.Compare(r, expected)
if len(diff) > 0 {
t.Errorf("String didn't match:\n%s", diff)
}
}