Esempio n. 1
0
func init() {
	msg := &memStatGauges{}

	metrics.Counter("Mem.NumGC").SetBatchFunc(key{}, msg.init, msg.numGC)
	metrics.Counter("Mem.PauseTotalNs").SetBatchFunc(key{}, msg.init, msg.totalPause)

	metrics.Gauge("Mem.LastGC").SetBatchFunc(key{}, msg.init, msg.lastPause)
	metrics.Gauge("Mem.Alloc").SetBatchFunc(key{}, msg.init, msg.alloc)
	metrics.Gauge("Mem.HeapObjects").SetBatchFunc(key{}, msg.init, msg.objects)
}
Esempio n. 2
0
func TestGaugeRemove(t *testing.T) {
	metrics.Reset()

	metrics.Gauge("whee").Set(1)
	metrics.Gauge("whee").Remove()

	_, gauges := metrics.Snapshot()
	if v, ok := gauges["whee"]; ok {
		t.Errorf("Gauge was %v, but expected nothing", v)
	}
}
Esempio n. 3
0
func init() {
	metrics.Gauge("FileDescriptors.Max").SetFunc(func() int64 {
		v, err := getFDLimit()
		if err != nil {
			return 0
		}
		return int64(v)
	})

	metrics.Gauge("FileDescriptors.Used").SetFunc(func() int64 {
		v, err := getFDUsage()
		if err != nil {
			return 0
		}
		return int64(v)
	})
}
Esempio n. 4
0
func TestGaugeValue(t *testing.T) {
	metrics.Reset()

	metrics.Gauge("whee").Set(-100)

	_, gauges := metrics.Snapshot()
	if v, want := gauges["whee"], int64(-100); v != want {
		t.Errorf("Gauge was %v, but expected %v", v, want)
	}
}
Esempio n. 5
0
func BenchmarkGaugeSet(b *testing.B) {
	metrics.Reset()

	b.ReportAllocs()
	b.ResetTimer()

	b.RunParallel(func(pb *testing.PB) {
		for pb.Next() {
			metrics.Gauge("test2").Set(100)
		}
	})
}
Esempio n. 6
0
func init() {
	metrics.Gauge("Goroutines.Num").SetFunc(func() int64 {
		return int64(runtime.NumGoroutine())
	})
}