Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[productcatalog] span attributes update #336

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions docs/manual_span_attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
puckpuck marked this conversation as resolved.
Show resolved Hide resolved

## RecommendationService

Expand Down
8 changes: 4 additions & 4 deletions src/productcatalogservice/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
Expand Down