From 425da0b4503a694024a7ad454c0ae55041601c05 Mon Sep 17 00:00:00 2001 From: alex289 Date: Wed, 20 Nov 2024 21:25:45 +0100 Subject: [PATCH] feat: Add entity framework telemetry --- CleanArchitecture.AppHost/Program.cs | 1 - .../CleanArchitecture.ServiceDefaults.csproj | 1 + CleanArchitecture.ServiceDefaults/Extensions.cs | 7 ++++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CleanArchitecture.AppHost/Program.cs b/CleanArchitecture.AppHost/Program.cs index 737d164..607445d 100644 --- a/CleanArchitecture.AppHost/Program.cs +++ b/CleanArchitecture.AppHost/Program.cs @@ -14,7 +14,6 @@ var db = sqlServer.AddDatabase("Database", "clean-architecture"); builder.AddProject("CleanArchitecture-Api") - //.WithHealthCheck("Api Health") .WithOtlpExporter() .WithReference(redis) .WaitFor(redis) diff --git a/CleanArchitecture.ServiceDefaults/CleanArchitecture.ServiceDefaults.csproj b/CleanArchitecture.ServiceDefaults/CleanArchitecture.ServiceDefaults.csproj index ccc2414..f0eaa55 100644 --- a/CleanArchitecture.ServiceDefaults/CleanArchitecture.ServiceDefaults.csproj +++ b/CleanArchitecture.ServiceDefaults/CleanArchitecture.ServiceDefaults.csproj @@ -15,6 +15,7 @@ + diff --git a/CleanArchitecture.ServiceDefaults/Extensions.cs b/CleanArchitecture.ServiceDefaults/Extensions.cs index c6dc3d3..8705c03 100644 --- a/CleanArchitecture.ServiceDefaults/Extensions.cs +++ b/CleanArchitecture.ServiceDefaults/Extensions.cs @@ -14,14 +14,14 @@ namespace CleanArchitecture.ServiceDefaults; public static class Extensions { private const string AspireEnabled = "ASPIRE_ENABLED"; - + public static void AddServiceDefaults(this TBuilder builder) where TBuilder : IHostApplicationBuilder { if (builder.Configuration[AspireEnabled] != "true") { return; } - + builder.ConfigureOpenTelemetry(); builder.AddDefaultHealthChecks(); @@ -60,6 +60,7 @@ private static void ConfigureOpenTelemetry(this TBuilder builder) wher tracing.AddSource(builder.Environment.ApplicationName) .AddAspNetCoreInstrumentation() .AddGrpcClientInstrumentation() + .AddEntityFrameworkCoreInstrumentation() .AddHttpClientInstrumentation(); }); @@ -88,7 +89,7 @@ public static void MapDefaultEndpoints(this WebApplication app) { return; } - + if (app.Environment.IsDevelopment()) { app.MapHealthChecks("/health");