[hw-7] add metrics, tracing

This commit is contained in:
Никита Шубин
2025-07-26 14:15:40 +00:00
parent 342bd3f726
commit 4396bebe80
38 changed files with 717 additions and 36 deletions

View File

@@ -6,6 +6,7 @@ import (
"route256/cart/internal/domain/entity"
"route256/cart/internal/domain/model"
"route256/cart/internal/infra/http/metrics"
)
type storage = map[entity.UID]*entity.Cart
@@ -34,6 +35,7 @@ func (r *InMemoryRepository) AddItem(_ context.Context, userID entity.UID, item
}
r.storage[userID] = cart
metrics.SetInMemoryObjects(len(r.storage))
}
if _, ok := cart.ItemCount[item.Product.Sku]; !ok {
@@ -112,6 +114,7 @@ func (r *InMemoryRepository) DeleteItemsByUserID(_ context.Context, userID entit
_, ok := r.storage[userID]
if ok {
delete(r.storage, userID)
metrics.SetInMemoryObjects(len(r.storage))
}
return nil