From 28ed0f4258b340db29be227d97fbd74d9412db2c Mon Sep 17 00:00:00 2001 From: Juliano Costa Date: Thu, 12 Dec 2024 15:21:04 +0100 Subject: [PATCH] Add source and meter --- src/cartservice/src/Program.cs | 2 ++ src/cartservice/src/cartservice.csproj | 2 +- src/cartservice/src/cartstore/ValkeyCartStore.cs | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cartservice/src/Program.cs b/src/cartservice/src/Program.cs index cb41bdb304..399d3d107d 100644 --- a/src/cartservice/src/Program.cs +++ b/src/cartservice/src/Program.cs @@ -61,6 +61,7 @@ builder.Services.AddOpenTelemetry() .ConfigureResource(appResourceBuilder) .WithTracing(tracerBuilder => tracerBuilder + .AddSource("OpenTelemetry.Demo.Cart.Source") .AddRedisInstrumentation( options => options.SetVerboseDatabaseStatements = true) .AddAspNetCoreInstrumentation() @@ -68,6 +69,7 @@ .AddHttpClientInstrumentation() .AddOtlpExporter()) .WithMetrics(meterBuilder => meterBuilder + .AddMeter("OpenTelemetry.Demo.Cart.Meter") .AddProcessInstrumentation() .AddRuntimeInstrumentation() .AddAspNetCoreInstrumentation() diff --git a/src/cartservice/src/cartservice.csproj b/src/cartservice/src/cartservice.csproj index b3ac8927f7..d62a131f7f 100644 --- a/src/cartservice/src/cartservice.csproj +++ b/src/cartservice/src/cartservice.csproj @@ -30,7 +30,7 @@ - + diff --git a/src/cartservice/src/cartstore/ValkeyCartStore.cs b/src/cartservice/src/cartstore/ValkeyCartStore.cs index ffdf14a962..1410be86d0 100644 --- a/src/cartservice/src/cartstore/ValkeyCartStore.cs +++ b/src/cartservice/src/cartstore/ValkeyCartStore.cs @@ -25,8 +25,8 @@ public class ValkeyCartStore : ICartStore private readonly byte[] _emptyCartBytes; private readonly string _connectionString; - private static readonly ActivitySource CartActivitySource = new("OpenTelemetry.Demo.Cart"); - private static readonly Meter CartMeter = new Meter("OpenTelemetry.Demo.Cart"); + private static readonly ActivitySource CartActivitySource = new("OpenTelemetry.Demo.Cart.Source"); + private static readonly Meter CartMeter = new Meter("OpenTelemetry.Demo.Cart.Meter"); private static readonly Histogram addItemHistogram = CartMeter.CreateHistogram("app.cart.add_item.latency"); private static readonly Histogram getCartHistogram = CartMeter.CreateHistogram("app.cart.get_cart.latency");