Skip to content

Commit

Permalink
feat: Add entity framework telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
alex289 committed Nov 20, 2024
1 parent 7d0ac81 commit 425da0b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 0 additions & 1 deletion CleanArchitecture.AppHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
var db = sqlServer.AddDatabase("Database", "clean-architecture");

builder.AddProject<Projects.CleanArchitecture_Api>("CleanArchitecture-Api")
//.WithHealthCheck("Api Health")
.WithOtlpExporter()
.WithReference(redis)
.WaitFor(redis)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.10.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.10.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.EntityFrameworkCore" Version="1.0.0-beta.12" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.9.0-beta.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.9.0" />
Expand Down
7 changes: 4 additions & 3 deletions CleanArchitecture.ServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ namespace CleanArchitecture.ServiceDefaults;
public static class Extensions
{
private const string AspireEnabled = "ASPIRE_ENABLED";

public static void AddServiceDefaults<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
if (builder.Configuration[AspireEnabled] != "true")
{
return;
}

builder.ConfigureOpenTelemetry();

builder.AddDefaultHealthChecks();
Expand Down Expand Up @@ -60,6 +60,7 @@ private static void ConfigureOpenTelemetry<TBuilder>(this TBuilder builder) wher
tracing.AddSource(builder.Environment.ApplicationName)
.AddAspNetCoreInstrumentation()
.AddGrpcClientInstrumentation()
.AddEntityFrameworkCoreInstrumentation()
.AddHttpClientInstrumentation();
});

Expand Down Expand Up @@ -88,7 +89,7 @@ public static void MapDefaultEndpoints(this WebApplication app)
{
return;
}

if (app.Environment.IsDevelopment())
{
app.MapHealthChecks("/health");
Expand Down

0 comments on commit 425da0b

Please sign in to comment.