Beispiel #1
0
func TestGetOrRegisterInstrument(t *testing.T) {
	r := NewRegistry()
	r.Register("foo", instruments.NewRate())
	i := r.Register("foo", instruments.NewGauge(0))
	if _, ok := i.(*instruments.Rate); !ok {
		t.Fatal("wrong instrument type")
	}
	registered := r.Instruments()
	if len(registered) != 1 {
		t.Fatal("registry should only have one instruments registered")
	}
	i, p := registered["foo"]
	if !p {
		t.Fatal("instrument not found")
	}
	if _, ok := i.(*instruments.Rate); !ok {
		t.Fatal("wrong instrument type")
	}
}
Beispiel #2
0
// NewStack creates a new Stack.
func NewStack() *Stack {
	return &Stack{
		g: instruments.NewGauge(0),
	}
}
Beispiel #3
0
// NewHeap creates a new Heap.
func NewHeap() *Heap {
	return &Heap{
		g: instruments.NewGauge(0),
	}
}
Beispiel #4
0
// NewAllocated creates a new Allocated.
func NewAllocated() *Allocated {
	return &Allocated{
		g: instruments.NewGauge(0),
	}
}
Beispiel #5
0
// NewCgo creats a new Cgo.
func NewCgo() *Cgo {
	return &Cgo{
		g: instruments.NewGauge(0),
	}
}
Beispiel #6
0
// NewGoroutine creats a new Goroutine.
func NewGoroutine() *Goroutine {
	return &Goroutine{
		g: instruments.NewGauge(0),
	}
}