Example #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")
	}
}
Example #2
0
// NewStack creates a new Stack.
func NewStack() *Stack {
	return &Stack{
		g: instruments.NewGauge(0),
	}
}
Example #3
0
// NewHeap creates a new Heap.
func NewHeap() *Heap {
	return &Heap{
		g: instruments.NewGauge(0),
	}
}
Example #4
0
// NewAllocated creates a new Allocated.
func NewAllocated() *Allocated {
	return &Allocated{
		g: instruments.NewGauge(0),
	}
}
Example #5
0
// NewCgo creats a new Cgo.
func NewCgo() *Cgo {
	return &Cgo{
		g: instruments.NewGauge(0),
	}
}
Example #6
0
// NewGoroutine creats a new Goroutine.
func NewGoroutine() *Goroutine {
	return &Goroutine{
		g: instruments.NewGauge(0),
	}
}