diff --git a/cart-grain.go b/cart-grain.go index c33c899..96f1a23 100644 --- a/cart-grain.go +++ b/cart-grain.go @@ -112,6 +112,7 @@ func (c *CartGrain) HandleMessage(message *Message, isReplay bool) ([]byte, erro now := time.Now().Unix() message.TimeStamp = &now } + grainMutations.Inc() var err error switch message.Type { case AddRequestType: diff --git a/grain-pool.go b/grain-pool.go index 56f22d2..061d9a3 100644 --- a/grain-pool.go +++ b/grain-pool.go @@ -81,6 +81,7 @@ func (p *GrainLocalPool) GetGrains() map[CartId]*CartGrain { func (p *GrainLocalPool) GetGrain(id CartId) (*CartGrain, error) { var err error grain, ok := p.grains[id] + grainLookups.Inc() if grain == nil || !ok { if len(p.grains) >= p.PoolSize { if p.expiry[0].Expires.Before(time.Now()) { diff --git a/main.go b/main.go index 391648b..5e0f086 100644 --- a/main.go +++ b/main.go @@ -14,14 +14,22 @@ import ( ) var ( - opsProcessed = promauto.NewCounter(prometheus.CounterOpts{ + grainSpawns = promauto.NewCounter(prometheus.CounterOpts{ Name: "cart_grain_spawned_total", Help: "The total number of spawned grains", }) + grainMutations = promauto.NewCounter(prometheus.CounterOpts{ + Name: "cart_grain_mutations_total", + Help: "The total number of mutations", + }) + grainLookups = promauto.NewCounter(prometheus.CounterOpts{ + Name: "cart_grain_lookups_total", + Help: "The total number of lookups", + }) ) func spawn(id CartId) (*CartGrain, error) { - opsProcessed.Inc() + grainSpawns.Inc() ret := &CartGrain{ Id: id, Items: []CartItem{},