diff --git a/src/cartservice/src/cartservice.csproj b/src/cartservice/src/cartservice.csproj
index a9aaa02c6d..33ba96d038 100644
--- a/src/cartservice/src/cartservice.csproj
+++ b/src/cartservice/src/cartservice.csproj
@@ -8,13 +8,12 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/src/cartservice/src/services/CartService.cs b/src/cartservice/src/services/CartService.cs
index 19c31abc40..a44b4f372e 100644
--- a/src/cartservice/src/services/CartService.cs
+++ b/src/cartservice/src/services/CartService.cs
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+using System.Diagnostics;
using System.Threading.Tasks;
using Grpc.Core;
using cartservice.cartstore;
@@ -31,17 +32,30 @@ public CartService(ICartStore cartStore)
public async override Task AddItem(AddItemRequest request, ServerCallContext context)
{
+ var activity = Activity.Current;
+ activity?.SetTag("app.user.id", request.UserId);
+ activity?.SetTag("app.product.id", request.Item.ProductId);
+ activity?.SetTag("app.product.quantity", request.Item.Quantity);
+
await _cartStore.AddItemAsync(request.UserId, request.Item.ProductId, request.Item.Quantity);
return Empty;
}
public override Task GetCart(GetCartRequest request, ServerCallContext context)
{
+ var activity = Activity.Current;
+ activity?.SetTag("app.user.id", request.UserId);
+ activity?.AddEvent(new("Fetch cart"));
+
return _cartStore.GetCartAsync(request.UserId);
}
public async override Task EmptyCart(EmptyCartRequest request, ServerCallContext context)
{
+ var activity = Activity.Current;
+ activity?.SetTag("app.user.id", request.UserId);
+ activity?.AddEvent(new("Empty cart"));
+
await _cartStore.EmptyCartAsync(request.UserId);
return Empty;
}