From 11834cca2b001ce6334a4d4c6deb5582198e10f4 Mon Sep 17 00:00:00 2001 From: Pierre Tessier Date: Tue, 23 Aug 2022 11:54:16 -0400 Subject: [PATCH] [productcatalog] span attributes update (#336) * update span attributes * update product catalog span attributes --- docs/manual_span_attributes.md | 11 ++++++----- src/productcatalogservice/main.go | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/manual_span_attributes.md b/docs/manual_span_attributes.md index 356f7d66ae..1f7d0000a0 100644 --- a/docs/manual_span_attributes.md +++ b/docs/manual_span_attributes.md @@ -88,11 +88,12 @@ This document contains the list of manual Span Attributes used throughout the de ## ProductCatalogService -| Name | Type | Description | -|----------------------|--------|---------------------------------------| -| `app.product.id` | string | Product Id | -| `app.product.name` | string | Product name | -| `app.products.count` | number | Number of products returned in search | +| Name | Type | Description | +|-----------------------------|--------|---------------------------------------| +| `app.product.id` | string | Product Id | +| `app.product.name` | string | Product name | +| `app.products.count` | number | Number of products in catalog | +| `app.products_search.count` | number | Number of products returned in search | ## RecommendationService diff --git a/src/productcatalogservice/main.go b/src/productcatalogservice/main.go index 1e9457b63c..270cb1a0a3 100644 --- a/src/productcatalogservice/main.go +++ b/src/productcatalogservice/main.go @@ -41,8 +41,8 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/status" ) var ( @@ -113,7 +113,7 @@ func readCatalogFile() []*pb.Product { if err := protojson.Unmarshal(catalogJSON, &res); err != nil { log.Fatalf("Parsing Catalog JSON: %v", err) } - + return res.Products } @@ -186,11 +186,11 @@ func (p *productCatalog) SearchProducts(ctx context.Context, req *pb.SearchProdu for _, product := range catalog { if strings.Contains(strings.ToLower(product.Name), strings.ToLower(req.Query)) || strings.Contains(strings.ToLower(product.Description), strings.ToLower(req.Query)) { - result = append(result, product) + result = append(result, product) } } span.SetAttributes( - attribute.Int("app.products.count", len(result)), + attribute.Int("app.products_search.count", len(result)), ) return &pb.SearchProductsResponse{Results: result}, nil }