[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/tracing"
pbLoms "route256/pkg/api/loms/v1"
)
@@ -21,6 +22,9 @@ func NewLomsService(grpcClient pbLoms.LOMSClient) *Service {
}
func (s *Service) OrderCreate(ctx context.Context, cart *model.Cart) (int64, error) {
ctx, span := tracing.Tracer().Start(ctx, "Loms.OrderCreate")
defer span.End()
items := make([]*pbLoms.OrderItem, len(cart.Items))
for i, item := range cart.Items {
items[i] = &pbLoms.OrderItem{
@@ -43,6 +47,9 @@ func (s *Service) OrderCreate(ctx context.Context, cart *model.Cart) (int64, err
}
func (s *Service) StocksInfo(ctx context.Context, sku entity.Sku) (uint32, error) {
ctx, span := tracing.Tracer().Start(ctx, "Loms.StocksInfo")
defer span.End()
req := &pbLoms.StocksInfoRequest{
Sku: int64(sku),
}